Keyword

WOW ! Major K2 design issue...

  • Sébastien Auclair
  • Sébastien Auclair's Avatar Topic Author
  • Offline
  • New Member
More
14 years 1 month ago #87023 by Sébastien Auclair
Replied by Sébastien Auclair on topic WOW ! Major K2 design issue...
No it adds the menu item id of 'a' page... and the logic to choose which page gets return by this K2HelperRoute::_findItem function is quite weird... I strongly suspect it's a bug as it adds stuff to the global URI that should really not be there.

The rest of the code adds the proper item id of the item i wish to view.

Olivier Nolbert said:Sébastien, The goal of this function is TO ADD AN ITEMID to K2 links (category, user, item, ...)

I think you'll get some other troubles commenting these lines.

Olivier


Sébastien Auclair said:Solution Found ! Had to change function K2HelpRoute::getItemRoute in route.php under the helpers directory.
For some reason, it was adding a menu item id which seams to me like something not very usefull !
I simply commented that part out.
class K2HelperRoute
{

function getItemRoute($id, $catid = 0) {

$needles = array (
'item'=>(int)$id,
'itemlist'=>(int)$catid,
);
$link = 'index.php?option=com_k2&view=item&id='.$id;

//if ($item = K2HelperRoute::_findItem($needles)) {
// $link .= '&Itemid='.$item->id;
//}

return $link;
}

Now, when you click on a Newsflash item under the "Home" page or the "News" page, the link to it becomes conventional as it should be:
www.mysite.com/component/k2/item/73-theselecteditem...

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
13 years 10 months ago #87024 by Nick Texidor
Replied by Nick Texidor on topic WOW ! Major K2 design issue...
I've just been looking into this area as the K2HelperRoute::getItemRoute isn't returning an itemid for me.

The problem I've discovered, is that when I call the getItemRoute with the Id, and CatId, of the item, it never matches the K2 menu item. The reason is that _findItem is checking categories, but not child categories. So for example, if I'm trying to find the correct route for K2 Item Id 1 which is in Category Id 2 (Category Id 2 being a Sub Category of Category Id 1), it never finds it because my main K2 page is told to display the parent category (with Category Id of 1). The only way I can see around this is to select the parent AND all the sub-categories on the main K2 page.

haha... did that make sense?? Basically, I think there's a problem with the _findItem function not taking child categories into account.

N



Olivier Nolbert said:Sébastien,
The goal of this function is TO ADD AN ITEMID to K2 links (category, user, item, ...)

I think you'll get some other troubles commenting these lines.

Olivier


Sébastien Auclair said:Solution Found ! Had to change function K2HelpRoute::getItemRoute in route.php under the helpers directory.

For some reason, it was adding a menu item id which seams to me like something not very usefull !
I simply commented that part out.
class K2HelperRoute
{

function getItemRoute($id, $catid = 0) {

$needles = array (
'item'=>(int)$id,
'itemlist'=>(int)$catid,
);
$link = 'index.php?option=com_k2&view=item&id='.$id;

//if ($item = K2HelperRoute::_findItem($needles)) {
// $link .= '&Itemid='.$item->id;
//}

return $link;
}

Now, when you click on a Newsflash item under the "Home" page or the "News" page, the link to it becomes conventional as it should be:
www.mysite.com/component/k2/item/73-theselecteditem...

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

More
13 years 10 months ago #87025 by Jiliko.net
Replied by Jiliko.net on topic WOW ! Major K2 design issue...
Hi Nick,

The getItemRoute function is used to retrieve an Itemid associated to the item id or the id of the item category.

If you need an Itemid returned for a specific category or subcategory, maybe you could just create the corresponding menu.

Olivier

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

  • Nick Texidor
  • Nick Texidor's Avatar
  • Visitor
13 years 10 months ago #87026 by Nick Texidor
Replied by Nick Texidor on topic WOW ! Major K2 design issue...
Hi Olivier,

Sure, I appreciate it's trying to return the item id of the menu item. The problem is, the Menu Item I have is pointing to the parent category, and showing all child categories. So in my K2DynaMap extension, when I display markers to the K2 Items, the getItemRoute can't find the menu item of the parent category, so I end up with the incorrect set of modules. Ideally, the getItemRoute should probably check the parent category of an item if it can't find any matches on it's own category id.

N



Olivier Nolbert said:Hi Nick,
The getItemRoute function is used to retrieve an Itemid associated to the item id or the id of the item category.

If you need an Itemid returned for a specific category or subcategory, maybe you could just create the corresponding menu.

Olivier

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

More
13 years 3 months ago #87027 by C. Zanardi
Replied by C. Zanardi on topic WOW ! Major K2 design issue...
Hello Nick,

 

Your message opened my eyes on the problem. It is true that K2 when you are using the getItemRoute function is trying to find the Itemid but it is not trying to find in children categories even if the menu is using this feature (the catCatalogMode parameter).

 

I have modified the route.php in the com_k2/helpers directory to include all children using the K2ModelItemlist::getCategoryChilds method:

 

$catCatalogMode = $menuparams->get('catCatalogMode');                        require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'models'.DS.'itemlist.php');              $allChildren = array();            foreach ($catids as $a_cat_id) {              $categories = K2ModelItemlist::getCategoryChilds($a_cat_id, true);              $categories[] = $a_cat_id;              $categories = @array_unique($categories);              $allChildren = @array_merge($allChildren, $categories);            }            $catids = @array_unique($allChildren);

 

From my point of view it is a bug.

 

Hope that helps.

 

Best regards,

 

Christian.

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


Powered by Kunena Forum