netstepinc Posted August 27, 2015 Share Posted August 27, 2015 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 changelogincludes/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')); }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 27, 2015 Share Posted August 27, 2015 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? if the documentation and/or support don't tell you how, then the only way will be by trial and error. 0 Quote Link to comment Share on other sites More sharing options...
netstepinc Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) 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 August 27, 2015 by netstepinc 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted August 27, 2015 Share Posted August 27, 2015 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'); }); 1 Quote Link to comment Share on other sites More sharing options...
netstepinc Posted August 27, 2015 Author Share Posted August 27, 2015 SWEET! Thank you. setAttribute isn't on the menu class page. Is it covered elsewhere? http://docs.whmcs.com/classes/classes/WHMCS.View.Menu.Item.html 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 27, 2015 Share Posted August 27, 2015 (edited) 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. 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! 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. Edited August 27, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted August 27, 2015 Share Posted August 27, 2015 SWEET! Thank you.setAttribute isn't on the menu class page. Is it covered elsewhere? http://docs.whmcs.com/classes/classes/WHMCS.View.Menu.Item.html no it's not covered in documentation 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted August 27, 2015 Share Posted August 27, 2015 @brian totally agree, and yes i found it after many tests, checking the document doesn't give me anything ! they added the ability to specify "target" in menu items http://docs.whmcs.com/Changelog:WHMCS_V6.0.2 but how to use this ability? what to write? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.