- Posts: 16
COMMUNITY FORUM
Assigning ItemId when showing only featured items
- Daniele Grassi
-
Topic Author
- Offline
- New Member
Less
More
14 years 8 months ago #87201
by Daniele Grassi
Assigning ItemId when showing only featured items was created by Daniele Grassi
Hi!I've a problem with the ItemId assigned by K2 when I click on the "READ MORE" of a featured article, in a view where only featured articles are listed. K2, in this case, doesn't assign an ItemId and I lose the modules configuration.Given a featured article, if a menu item links to its category (or to its parent), I need K2 to set the ItemId related to that menu item.I've modded the file helpers/route.php to get this result, but I was wondering if there is a "soft" way to obtain that.Thanks and best regards
Please Log in or Create an account to join the conversation.
- Martin Dean
-
- Offline
- New Member
Less
More
- Posts: 5
14 years 7 months ago #87202
by Martin Dean
Replied by Martin Dean on topic Assigning ItemId when showing only featured items
Hi Daniele,
Would you mind sharing any edits you made ?
I have featured items on a homepage pulling articles from withinin the categories live/articles/topic1,topic2.
the homepage is a default menulink to the articles category.
I have seperate menus topic1/articles and topic2/articles.
If the featured article on the homepage is from topic1, I want the readmore link to pass the itemid associated with the menu item topic1/articles.
Is this the configuration you meant ?
Would you mind sharing any edits you made ?
I have featured items on a homepage pulling articles from withinin the categories live/articles/topic1,topic2.
the homepage is a default menulink to the articles category.
I have seperate menus topic1/articles and topic2/articles.
If the featured article on the homepage is from topic1, I want the readmore link to pass the itemid associated with the menu item topic1/articles.
Is this the configuration you meant ?
Please Log in or Create an account to join the conversation.
- Casper Voogt
-
- Offline
- Junior Member
Less
More
- Posts: 22
14 years 3 months ago #87203
by Casper Voogt
Replied by Casper Voogt on topic Assigning ItemId when showing only featured items
I ran into this with tag views. Here is what I did. It may heklp you;
In my case, I use only tags, which I link to from my menu. So each tag has its own Itemid, which is fine. However, when you click on "read more" for any of the items on the generic tag page, the 'read more' link uses the default K2 Itemid rather than the Itemid of the current page / menu item. This does seem like a bug to me. The read more links should use the Itemids of the current page or at least the menu item that brought the viewer to that 'read more' link.
I have written a small override that solved this for me, since I could find no other way to solve this.
In /components/k2/models/item.php around line 62 (search for "read more link" .. it should be the first one), add this:
//mod to replace K2 Itemid with current page's Itemid.
if(JRequest::getVar('Itemid') && JRequest::getVar('layout') && (JRequest::getVar('layout') == 'generic') && JRequest::getVar('task') && (JRequest::getVar('task') == 'tag')){
//MAKE SURE TO CHANGE "Itemid=17" TO WHATEVER ITEMID YOUR K2 USES:
$link = str_replace('Itemid=17','Itemid='.JRequest::getInt('Itemid'),$link);
}
//end
In my case, I use only tags, which I link to from my menu. So each tag has its own Itemid, which is fine. However, when you click on "read more" for any of the items on the generic tag page, the 'read more' link uses the default K2 Itemid rather than the Itemid of the current page / menu item. This does seem like a bug to me. The read more links should use the Itemids of the current page or at least the menu item that brought the viewer to that 'read more' link.
I have written a small override that solved this for me, since I could find no other way to solve this.
In /components/k2/models/item.php around line 62 (search for "read more link" .. it should be the first one), add this:
//mod to replace K2 Itemid with current page's Itemid.
if(JRequest::getVar('Itemid') && JRequest::getVar('layout') && (JRequest::getVar('layout') == 'generic') && JRequest::getVar('task') && (JRequest::getVar('task') == 'tag')){
//MAKE SURE TO CHANGE "Itemid=17" TO WHATEVER ITEMID YOUR K2 USES:
$link = str_replace('Itemid=17','Itemid='.JRequest::getInt('Itemid'),$link);
}
//end
Please Log in or Create an account to join the conversation.