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

More
9 years 10 months ago - 9 years 10 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: 9 years 10 months ago by ggppdk.

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

More
9 years 10 months ago - 9 years 10 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: 9 years 10 months ago by ggppdk.

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

More
9 years 10 months ago - 9 years 10 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 review. Thanks!
Last edit: 9 years 10 months ago by ggppdk.

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

More
9 years 10 months ago - 9 years 10 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 review. Thanks!
Last edit: 9 years 10 months ago by ggppdk.

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

More
9 years 10 months ago - 9 years 10 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: 9 years 10 months ago by fortino.

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

More
9 years 10 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 review. Thanks!

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

More
9 years 10 months ago #61036 by fortino
Looks there's some issue.
I have two module both with a dynamic category [the same] and a static category [different]. They show the same items and this is not right.

I'm debugging right now.
I'll give you more infos soon.

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

More
9 years 10 months ago - 9 years 10 months ago #61039 by fortino
oook, after a day I figure out [mostly] what's going on.

the helper of this module doesn't merge STATIC and DYNAMIC categories.

As I said before I need to put in AND one static cat and one dynamic cat.

I found out a working solution:

helper.php, line 1070 :
Code:
if ($behaviour_cat == 1 || $behaviour_cat == 3) { if (!$apply_config_per_category) { $where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')'; } else {
replace with this:
Code:
if ($behaviour_cat == 1 || $behaviour_cat == 3) { /* SG MOD */ if ((!$apply_config_per_category)&&($cat_combine)){ $catids_arr = array_merge($catids_arr, $catids); $where .= ' AND i.id IN (' .' SELECT DISTINCT itemid' .' FROM #__flexicontent_cats_item_relations' .' WHERE catid IN ('.implode(',', $catids_arr).')' .' GROUP by itemid HAVING COUNT(*) >= '.count($catids_arr) .')' ; /* END SG MOD */ } else if(!$apply_config_per_category){ $where .= ' AND c.id IN (' . implode(',', $catids_arr) . ')'; } else {
Sorry if it's not the most elegant solution, I need more time to understand 100% the helper .
Last edit: 9 years 10 months ago by fortino.

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

More
9 years 9 months ago #61384 by fortino
Well, this issue is in the component too, just found out trying to have a multicategories view, not only the module.

One thing: the module isn't merging the dynamic and static categories... is my solution [last post] good enough?

Thank you

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

More
9 years 9 months ago #61386 by ggppdk
Question

1. trying to keep a balance of making powerful, but not too difficult to configure,

2. what is the percentage of web-sites or of a administrator of a set of web-sites that will use this ?

so do you still think it should be added ?


-- 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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
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
Save