- Posts: 33
COMMUNITY FORUM
Content Module Filter Problem
- John Comeskey
-
Topic Author
- Offline
- Junior Member
So the filter is corrupt.
Please Log in or Create an account to join the conversation.
- John Comeskey
-
Topic Author
- Offline
- Junior Member
- Posts: 33
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
- Platinum Member
- Posts: 8743
Please Log in or Create an account to join the conversation.
- John Comeskey
-
Topic Author
- Offline
- Junior Member
- Posts: 33
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
- Platinum Member
- Posts: 8743
Please Log in or Create an account to join the conversation.
- John Comeskey
-
Topic Author
- Offline
- Junior Member
- Posts: 33
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
- Posts: 15
Thanks, and keep the good stuff comming ;)
Please Log in or Create an account to join the conversation.
- Colin Salomons
-
- Offline
- New Member
- Posts: 2
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
- Posts: 15
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
- Posts: 10
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.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
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.
- John Comeskey
-
Topic Author
- Offline
- Junior Member
- Posts: 33
It would be better if you would either post the correct code here or release an updated version of the entire module.
Lefteris Kavadas said:Hi. Thanks for posting this mod but i think that it will break in PHP 4. We have implemented a little different patch for this. You can always view the latest source from the Joomlaworks svn repository on google code.
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.
- Colin Salomons
-
- Offline
- New Member
- Posts: 2
Lefteris Kavadas said:Hi. Thanks for posting this mod but i think that it will break in PHP 4. We have implemented a little different patch for this. You can always view the latest source from the Joomlaworks svn repository on google code.
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.
- Kenneth Crowder
-
- Offline
- New Member
- Posts: 5
I came here to post my fix to this issue, but realized your fix is much cleaner. +5 points for you!
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.