- Posts: 157
COMMUNITY FORUM
Load K2 Tag Title for menu item
- Goble002
-
Topic Author
- Offline
- Premium Member
I have a menu item for a tag. I understand that in this case, tag.php will load 'Browser Page Title' and if not present 'Menu Title' as set for that menu item as the Title (before the item listings). In case there are no menu item for that Tag, then the Tag name will be loaded (assuming it's set in K2 Options)
I'm looking for a little tweak to load 'Tag Name' even though 'Browser Page Title' and 'Menu Title' are set.
Please Log in or Create an account to join the conversation.
- Goble002
-
Topic Author
- Offline
- Premium Member
- Posts: 157
Still stuck with that.
I have tried making a : <?php var_dump($this); ?>
But nothing returned the tag name
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
-
Topic Author
- Offline
- Premium Member
- Posts: 157
just need to load the k2 tag as title in the visible HTML ;-)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
<?php echo $item->name; ?>
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
-
Topic Author
- Offline
- Premium Member
- Posts: 157
Check the test here :
k2.securemu.com/index.php/menu-item-for-that-tag
This page is a Tag Menu Item for Tag "my test222 tag". The tag name should have been output just after the text: "My tag name should output here :" since your code appears just after this text in the HTML.
I have also done a VAR dump on this page. "my test222 tag" appears but I'm not sure which code loads it.
In settings > Tag Listings : only "Heading for tag listings", "Item title" and "Link on item title" is set to show.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
<?php echo $this->name; ?>
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
-
Topic Author
- Offline
- Premium Member
- Posts: 157
thanks for helping me out but unfortunately it won't output anything. Find hereunder all the codes that tag.php is loading actually :
<h3>My tag name should output here :
<?php echo $item->$name->tag; ?>
<?php echo $item->$tag->name; ?>
<?php echo $item->$tag->this; ?>
<?php echo $item->$this->tag; ?>
<?php echo $item->name; ?>
<?php echo $item->tag; ?>
<?php echo $item->title; ?>
<?php echo $tag->$name->this; ?>
<?php echo $tag->$this->name; ?>
<?php echo $tag->$item->this; ?>
<?php echo $tag->$this->item; ?>
<?php echo $tag->name; ?>
<?php echo $tag->item; ?>
<?php echo $tag->this; ?>
<?php echo $this->$name->tag; ?>
<?php echo $this->$tag->name; ?>
<?php echo $this->$item->tag; ?>
<?php echo $this->$tag->item; ?>
<?php echo $this->tag; ?>
<?php echo $this->item; ?>
<?php echo $this->name; ?>
</h3>
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
After this line github.com/getk2/k2/blob/master/components/com_k2/views/itemlist/view.html.php#L322 add this code:
$this->assignRef('name', $tag->name);
Then in your template you can call $this->name to output the raw tag value.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
-
Topic Author
- Offline
- Premium Member
- Posts: 157
$title = $params->get('page_title');
}
$this->assignRef('title', $title);
TO
$title = $params->get('page_title');
}
$this->assignRef('name', $tag->name);
$this->assignRef('title', $title);
Everything working perfectly !
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.