Some code thoughts - mod_flexicontent

More
12 years 2 weeks ago - 12 years 2 weeks ago #24304 by gruz
I'm looking at the modules/mod_flexicontent/helper.php
I will post my proposed changes in a while, but they will be minor and concern some features I need.

I have 2 suggestions:
1. There is a number of lines of the same code for featured and standart items. The difference is only in the _feat suffix. Altering such a code demands twice changins.
My suggestions is to move it to a function to call it with the suffix parameter - _feat or no. We can reduce the number of the code lines sugnificantly.

I can rewrite this, but I need to be sure it will be applied in the next buiilds.

2. When I want to show items's fields in the module
it requests firstly ALL the availabe fields here:
Code:
$rows = & FlexicontentFields::getFields($filtered_rows, 'module', $params);
[img


and later removes unneded. Is thir correct? Isn't it an overload? I'm not familiar with the code yet, but I think it would be better to create a function to fetch a field or a set of fields, but not all the universe of the fields. Function FlexicontentFields::getFields is a heavy one to be used in the module, as for me.
Maybe it's worth to create another function for frontend, much lighter.

But in this point I'm not sure. Maybe the data is loaded anyway on some other reason. This can tell someone more familiar with the code.

Still I can help with the code ecnhacement, but I must be sure I understand the logic in a right way not to make mistakes.

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)
Last edit: 12 years 2 weeks ago by gruz.

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #24305 by micker
ok i send it georgios
thanks for you return !!
regards

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #24307 by ggppdk
Actually this function is optimized.

-- It retrieves multiple field value for multiple items at once,
-- creates parameters once per field type

the other field you see there are core fields, maybe the "text" field could be an issue if you do not use it since it involves plugin triggering

the main bottleneck in performance is calling joomla content plugins ...

i plan on profiling the code to identify sections that may have room for improvement.

v1.5.6/v2.0 have a lot of performance improvements compared to v1.5.4/v1.5.5

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #24310 by gruz
Ok, the fields are loaded without overusing resources. I get a field from ANOTHER type when loading it via moduyle (like explained here www.flexicontent.org/documentati ... field.html . I can't image how, but ok (-:

And what about the code duplication?



Here are my current badly needed changes.

I want to output item's category name in the module. The context is concerned to this tutorial - www.flexicontent.org/documentati ... field.html

So I want to output some related fields and the category of the related type (the fields belong to the type).

Currently mod_flexicontent doesn't pass the category info to the module template. So I've added an option in the module to fetch it.
[img
[img


So the language string for
language/en-GB/en-GB.mod_flexicontent.ini
are (cool, multyline is supported)
Code:
FLEXI_GET_ITEM_CATEGORY_INFO="Fetch item category information?<a href='http://paste.opensuse.org/51623893' target='_blank'>[code]" FLEXI_GET_ITEM_CATEGORY_INFO_DESC="If yes, then you have the item category information accessibe in your module templates via $item->cats (array of objects). I.e. if you want to output the main category name, then the code should be like this <br><pre style='font-size:14px;'>foreach ($item->cats as $cat) { if ($cat->id == $item->catid) { echo $cat->title; break; } }</pre>"

and the here are the 2 modified files (my changes are marked with ##mygruz, so you can easily find them)
modules/mod_flexicontent/helper.php
paste.opensuse.org/23817185

and modules/mod_flexicontent/mod_flexicontent.xml

paste.opensuse.org/71483853

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #24311 by ggppdk
about duplicating code, yes we could unify it, about passing category info of the items to the template,

we could add item category info without this without having a new parameter (i 've added $item->itemcats an array of item's category ids) , will be on next public revision, (but most important i have some issues to fix)

Also because category info is commonly used we have a cached global array for category information (you do not need to queries categories table), use:

global $globalcats;

print it to see its structure

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #24312 by gruz
Damn... I want to cry... I spent 2 days in a rush to make it work as expected, altered dozens of files, outputted megatones of dump info.... And now you tell me use this 2 line:
Code:
global $globalcats; echo $globalcats[$item->catid]->title;

I really don't want to live futher... I mean thanks. I'm a "absolutelly useless monkey", like one my pal says.


The code duplication. Please looks at the helper.php

There is a line
Code:
if ($row->featured) { //and then 112 lines of code } else { //and then again the same code but without the _feat prefix, again 112 lines }

P.S.
Do you think such a simple name $globalcats in global context is safe? I think that FC shoud use a global namespace with a more unique name.
Besides Joomla removed global $mainfraime; on some reason. Maybe FC should move in the similar way. Maybe I'm saying something silly, then sorry.

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.317 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline