Keyword

Load K2 Tag Title for menu item

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 3 months ago #179343 by Goble002
Load K2 Tag Title for menu item was created by Goble002
Hello,

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
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 3 months ago #179362 by Goble002
Replied by Goble002 on topic Load K2 Tag Title for menu item
Hello,

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.

More
3 years 2 months ago #179438 by JoomlaWorks
Replied by JoomlaWorks on topic Load K2 Tag Title for menu item
Are you referring to what gets shown in the <title> HTML tag or the actual visible title of the page inside some h1 or h2 tag?

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
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 2 months ago #179469 by Goble002
Replied by Goble002 on topic Load K2 Tag Title for menu item
Thanks,

just need to load the k2 tag as title in the visible HTML ;-)

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

More
3 years 2 months ago #179482 by JoomlaWorks
Replied by JoomlaWorks on topic Load K2 Tag Title for menu item
Try this:

<?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
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 2 months ago #179522 by Goble002
Replied by Goble002 on topic Load K2 Tag Title for menu item
Thanks @Fotis but this would have been too easy ;-)

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.

More
3 years 2 months ago #179539 by JoomlaWorks
Replied by JoomlaWorks on topic Load K2 Tag Title for menu item
Sorry, my bad, it should be:

<?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
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 2 months ago #179545 by Goble002
Replied by Goble002 on topic Load K2 Tag Title for menu item
Hello Foris,

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.

More
3 years 1 month ago #179558 by JoomlaWorks
Replied by JoomlaWorks on topic Load K2 Tag Title for menu item
Do this.

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.

More
3 years 1 month ago #179559 by JoomlaWorks
Replied by JoomlaWorks on topic Load K2 Tag Title for menu item
I'll make sure to add it in K2 v2.11 coming out in a few days.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum