IMPORTANT MESSAGE REGARDING THE FORUM

As you may already know, the JoomlaWorks Forum is powered by Kunena (the only decent forum component for Joomla).

Unfortunately, the latest update for Kunena has seemingly broken all code snippets (old and new) in the forum.

Until this message is removed, please paste any code as regular text - in other words, don't use the [code]...[/code] tags in Kunena's post editor.

Keyword

Load K2 Tag Title for menu item

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
2 months 4 weeks 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.

My Stock Photo Website powered by k2 : explora.mu

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
2 months 2 weeks 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

My Stock Photo Website powered by k2 : explora.mu

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

More
1 month 3 weeks ago #179438 by Fotis
Replied by Fotis 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?

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
1 month 2 weeks 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 ;-)

My Stock Photo Website powered by k2 : explora.mu

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

More
1 month 2 weeks ago #179482 by Fotis
Replied by Fotis on topic Load K2 Tag Title for menu item
Try this:

<?php echo $item->name; ?>

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
1 month 4 days 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.

 

My Stock Photo Website powered by k2 : explora.mu

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

More
1 month 3 days ago #179539 by Fotis
Replied by Fotis on topic Load K2 Tag Title for menu item
Sorry, my bad, it should be:

<?php echo $this->name; ?>

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
1 month 2 days 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> 

 

My Stock Photo Website powered by k2 : explora.mu

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

More
1 month 10 hours ago #179558 by Fotis
Replied by Fotis 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.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

More
1 month 10 hours ago #179559 by Fotis
Replied by Fotis 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.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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


Powered by Kunena Forum