Jump to content

v6.02 Menu How to add Link Target Attribute


netstepinc

Recommended Posts

I want to redirect the Knowledgebase link to an external site via opening a new window.

How do I add a target attribute in the menu hook?

 

6.0.2 changelog

includes/navbar.tpl

Line 3: Add code to allow navbar links to have a "target" attribute.

Line 13: Add code to allow submenu links to have "target" attribute.

 

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$navItem = $primaryNavbar->getChild('Knowledgebase');
if (is_null($navItem)) {
	return;
}
$navItem->setUri('http://mydocumentation.com'));
});

Link to comment
Share on other sites

I posted this question after more than an hour or trial and error...just to learn how to get this spiffy new system to add, target="_blank" to a link. That's a bit annoying.

 

I have drilled through the documentation looking for attributes and looked at the syntax of the menu API and don't see the method.

 

I don't understand the syntax to add an attribute to a V6 menu item link. I was hoping, that since this appears to be a NEW feature in 6.0.2 that whoever put it into the system might be able to explain how I can use it.

 

 

If you can't help...maybe just don't comment?

If everyone just stewed in their own juice when they got stuck...there wouldn't be any questions in this forum.

Edited by netstepinc
Link to comment
Share on other sites

here is how you can implement it:

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$navItem = $primaryNavbar->getChild('Knowledgebase');
if (is_null($navItem)) {
 return;
}
$navItem->setUri('http://mydocumentation.com');
$navItem->setAttribute("target", '_blank');
});

Link to comment
Share on other sites

I posted this question after more than an hour or trial and error...just to learn how to get this spiffy new system to add, target="_blank" to a link. That's a bit annoying.

I absolutely agree - it took me hours how to figure out how to write the hook in the thread below... that took trial & error and a bit of lateral thinking...

 

http://forum.whmcs.com/showthread.php?104894-Login-to-cPanel-amp-Webmail-on-Client-Product-Details&p=432807#post432807

 

I have drilled through the documentation looking for attributes and looked at the syntax of the menu API and don't see the method.

 

I don't understand the syntax to add an attribute to a V6 menu item link. I was hoping, that since this appears to be a NEW feature in 6.0.2 that whoever put it into the system might be able to explain how I can use it.

aahh.. you're working under the assumption that the WHMCS developers read the forums - they don't... occasionally, during a beta period, they may grace us with their presence and even speak, but usually not otherwise... the forums are not a path to WHMCS support or developers... we're left to try and figure things out for ourselves. :twisted:

 

If you can't help...maybe just don't comment?

damned if I do, damned if I don't - if I don't post, you might think you're being ignored... I couldn't give you the answer for the simple reason that it's not in the documentation nor did I have the need to figure it out... i'm not to know you spent an hour trying different options am I ? telepathy failure alert.

 

you could reasonably ask why WHMCS introduce a new feature and then don't explain how to use it - but that's WHMCS for you. :)

 

anyway, sentq's just posted the solution (nice work btw) for you - perhaps he found it by trial & error! :idea:

 

If everyone just stewed in their own juice when they got stuck...there wouldn't be any questions in this forum.

I think more than anyone else, i'm fully aware of the questions that get asked in these forums... anyway, i'll let others help you in the future. :roll:

Edited by brian!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated