- Posts: 33
COMMUNITY FORUM
Content Module Filter Problem
- John Comeskey
- Topic Author
- Offline
- Junior Member
Less
More
15 years 1 month ago #73624
by John Comeskey
Content Module Filter Problem was created by John Comeskey
I am using the V2.1 content module to filter content from only one K2 category. But for some reason, only when I am viewing the excluded K2 categories, articles from the excluded categories are also appearing in the module list.
So the filter is corrupt.
So the filter is corrupt.
Please Log in or Create an account to join the conversation.
- John Comeskey
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
15 years 1 month ago #73625
by John Comeskey
Replied by John Comeskey on topic Content Module Filter Problem
UPDATE: It appears that the problem lies within the module parameter for "Fetch items from children categories". If set to yes, then the filter gets confused and included items from excluded categories - even when these excluded categories are NOT children of the selected categories. When set to no, then the filter seems to behave properly.
Also, this behavior was observed when item ordering was using 'highest rated' and when items from all categories had no ratings.
Also, this behavior was observed when item ordering was using 'highest rated' and when items from all categories had no ratings.
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
15 years 1 month ago #73626
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Content Module Filter Problem
Hi. I m trying to reproduce the bug but no luck yet. It works fine for me. Are you completely sure that you are using the latest version of K2? Also what's the PHP version you are using?
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- John Comeskey
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
15 years 1 month ago #73627
by John Comeskey
Replied by John Comeskey on topic Content Module Filter Problem
OK, double checking now. K2 component version is 2.1. Mod_k2_content is also version 2.1. PHP 5.2.10.
Try this: Set up two top-level K2 categories. Create a couple of items in each category, but do not post any ratings.
Set up your module to filter by just one of your categories. Set Fetch items from children categories to Yes. Set item ordering to Highest Rated. Publish it to all pages of the site.
Then from the front end, check it from a page in the excluded category to see if an item from the excluded category is listed in the module.
Lefteris Kavadas said:Hi. I m trying to reproduce the bug but no luck yet. It works fine for me. Are you completely sure that you are using the latest version of K2? Also what's the PHP version you are using?
Try this: Set up two top-level K2 categories. Create a couple of items in each category, but do not post any ratings.
Set up your module to filter by just one of your categories. Set Fetch items from children categories to Yes. Set item ordering to Highest Rated. Publish it to all pages of the site.
Then from the front end, check it from a page in the excluded category to see if an item from the excluded category is listed in the module.
Lefteris Kavadas said:Hi. I m trying to reproduce the bug but no luck yet. It works fine for me. Are you completely sure that you are using the latest version of K2? Also what's the PHP version you are using?
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
15 years 1 month ago #73628
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Content Module Filter Problem
Hi again. OK you are totally correct. The bug occurs when the module is on a category page. It has been fixed for the next release. Thanks for reporting this issue to us.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- John Comeskey
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 33
15 years 1 month ago #73629
by John Comeskey
Replied by John Comeskey on topic Content Module Filter Problem
Thanks! Those of us who use extensions for free have an obligation to at least contribute through bug reporting, testing, and forum contribution.
Lefteris Kavadas said:It has been fixed for the next release. Thanks for reporting this issue to us.
Lefteris Kavadas said:It has been fixed for the next release. Thanks for reporting this issue to us.
Please Log in or Create an account to join the conversation.
- Kormann
- Offline
- New Member
Less
More
- Posts: 15
15 years 1 month ago #73630
by Kormann
Replied by Kormann on topic Content Module Filter Problem
Oh I got this bug also! I was looking for a solution but you Lefteris Kavadas said it is already fixed for the next release.. Hmm, can you upload this fix or just point us your svn where it is fixed? I'm quiting my job and I need my current site done until monday, so if I could use your fix I would be glad.
Thanks, and keep the good stuff comming ;)
Thanks, and keep the good stuff comming ;)
Please Log in or Create an account to join the conversation.
- Colin Salomons
- Offline
- New Member
Less
More
- Posts: 2
15 years 1 week ago #73631
by Colin Salomons
Replied by Colin Salomons on topic Content Module Filter Problem
You have to edit function getCategoryChilds in components/com_k2/models/itemlist.php. The problem is that static array. Here is what I replaced it with:
function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
Please Log in or Create an account to join the conversation.
- Kormann
- Offline
- New Member
Less
More
- Posts: 15
14 years 11 months ago #73632
by Kormann
Replied by Kormann on topic Content Module Filter Problem
Thank you man!
It worked flawessly! :D
Colin Salomons said:You have to edit function getCategoryChilds in components/com_k2/models/itemlist.php. The problem is that static array. Here is what I replaced it with:
function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
It worked flawessly! :D
Colin Salomons said:You have to edit function getCategoryChilds in components/com_k2/models/itemlist.php. The problem is that static array. Here is what I replaced it with:
function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
Please Log in or Create an account to join the conversation.
- Augusto Pissarra
- Offline
- New Member
Less
More
- Posts: 10
14 years 11 months ago #73633
by Augusto Pissarra
Replied by Augusto Pissarra on topic Content Module Filter Problem
Colin, tks for solution. This also solves a even more serious problem. When you set to fetch sub-categories, if you put 2 content modules in the same page, it only takes the articles of the last first category module.
Anyhow, taking the static array out, also solve the above problem.
Great job!
Kormann said:Thank you man! It worked flawessly! :D
Colin Salomons said:You have to edit function getCategoryChilds in components/com_k2/models/itemlist.php. The problem is that static array. Here is what I replaced it with: function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
Anyhow, taking the static array out, also solve the above problem.
Great job!
Kormann said:Thank you man! It worked flawessly! :D
Colin Salomons said:You have to edit function getCategoryChilds in components/com_k2/models/itemlist.php. The problem is that static array. Here is what I replaced it with: function getCategoryChilds($catid, &$array=array()) {
$user = &JFactory::getUser();
$aid = $user->get('aid');
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->id);
if (K2ModelItemlist::hasChilds($row->id)) {
K2ModelItemlist::getCategoryChilds($row->id, $array);
}
}
return $array;
}
Please Log in or Create an account to join the conversation.