[SOLVED] mod_flexicontent category scope behaviour is ANY category, without option to configure REQUIRE ALL

More
8 years 7 months ago - 8 years 7 months ago #60606 by fortino
Hi again, sorry to "bug" you but I'm developing a huge site using flexicontent and I'll report every bug [or presumed bug] I find.

This time I find out something weird about the scope in the flexicontent module.

I've items with multiple categories.
My target is to show items in the current active category AND in the static category specified in the module configuration.
Looks like they are in OR and not in AND...

I hope I'm clear...

Can you suggest me a solution?
Last edit: 8 years 7 months ago by ggppdk.

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

More
8 years 7 months ago - 8 years 7 months ago #60608 by fortino
WELL, this is defnitely not a bug but the way this module works.

I modified the helper and the xml to have an option about the "query's logic" [AND / OR].


modules/mod_flexicontent/helper.php
row 1692 to 1731, replace with this:
Code:
if( $params->get('cat_and_or', 0) ==0 ){ $items_query = 'SELECT ' . ' i.id ' . (in_array('commented', $ordering) ? $select_comments : '') . (in_array('rated', $ordering) ? $select_rated : '') . ' FROM #__flexicontent_items_tmp AS i' . ' JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' JOIN #__flexicontent_types AS ty on ie.type_id = ty.id' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id' . ' JOIN #__categories AS c ON c.id = rel.catid' . ' JOIN #__categories AS mc ON mc.id = i.catid' . $joinaccess . $join_favs . $join_date . (in_array('commented', $ordering) ? $join_comments : '') . (in_array('rated', $ordering) ? $join_rated : '') . $orderby_join . $join_field_filters . $where .' '. ($apply_config_per_category ? '__CID_WHERE__' : '') . $where_field_filters . ' GROUP BY i.id' . $orderby ; } else{ $items_query = 'SELECT ' . ' i.id ' . (in_array('commented', $ordering) ? $select_comments : '') . (in_array('rated', $ordering) ? $select_rated : '') . ' FROM ' . ' (SELECT COUNT(rel2.itemid), rel2.itemid FROM rl2k16_flexicontent_cats_item_relations AS rel2 WHERE catid IN ('.implode(",",array_merge($catids, $catids_arr)).') GROUP BY rel2.itemid HAVING COUNT(*) > '.(count(array_merge($catids, $catids_arr))-1).') as guzzo,' . ' #__flexicontent_items_tmp AS i' . ' JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' JOIN #__flexicontent_types AS ty on ie.type_id = ty.id' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id' . ' JOIN #__categories AS c ON c.id = rel.catid' . ' JOIN #__categories AS mc ON mc.id = i.catid' . $joinaccess . $join_favs . $join_date . (in_array('commented', $ordering) ? $join_comments : '') . (in_array('rated', $ordering) ? $join_rated : '') . $orderby_join . $join_field_filters . $where .' '. ($apply_config_per_category ? '__CID_WHERE__' : '') . ' AND i.id = guzzo.itemid ' . $where_field_filters . ' GROUP BY i.id' . $orderby ; }

modules/mod_flexicontent/mod_flexicontent.xml
INSERT this in after row 235 and before 236:
Code:
<field name="cat_and_or" type="list" default="0" label="AND / OR?" description="AND / OR?" class="method_cat_ops" > <option value="0">OR</option> <option value="1">AND</option> </field>


Hope this will help someone! B)
Please don't be shy and suggest me a better query if you feel to. I'm not a db wizard!
Last edit: 8 years 7 months ago by ggppdk.

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

More
8 years 7 months ago - 8 years 7 months ago #60664 by ggppdk
Hello

the count-having is a bit heavy,
thus it is better to optimize by doing an
AND i.id IN (.... count-having....)

like we do for tags

PS: the TAGS require ALL was broken because of wrong parameter name

Here is the new files (fixed TAGs require ALL and added CATS require ALL)
github.com/FLEXIcontent/flexicontent-cck...501033f28483cd3b7499




-- 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...
Attachments:
Last edit: 8 years 7 months ago by ggppdk.

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

More
8 years 7 months ago - 8 years 7 months ago #60665 by ggppdk
Hello

also the code must not be activated if:
- if you select "Exclude categories"
- if you enable "Apply configuration per category"

thus the new code will activate on if "Include categories" is enabled


-- 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...
Last edit: 8 years 7 months ago by ggppdk.

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

More
8 years 7 months ago - 8 years 7 months ago #60671 by fortino
great, I had not time to improve the query.. I had a beta demo 2 days ago I need the module to work quickly.

I think this behaviour is correct both for include and exclude option.

Thank you very much
Last edit: 8 years 7 months ago by fortino.

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

More
8 years 7 months ago #60674 by ggppdk
Hello

as i said above we already commited this for v3.0.14,
so that it works properly with the rest of module parameters

there is no need to work on it more
here is v3.0.14-beta
github.com/FLEXIcontent/flexicontent-cck/releases


-- 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.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.300 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