paperweight Posted May 12, 2016 Share Posted May 12, 2016 (edited) Hello: I am using the code below to create a new Primary NavBar with 3 child links beneath it. However, only the main NavBar and one of the child links (the one labeled "custom_clouddetails_3") appear -- it seems like the 2 child links in the middle are hidden. Can you pls check my syntax below and tell me where I made a mistake? Thank you so much~ add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild(Lang::trans('custom_clouddetails')) ->setUri('http://www.mydomain.com/custom-clouddetails.php') ->setOrder(70); }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild(Lang::trans('custom_clouddetails')))) { $primaryNavbar->getChild(Lang::trans('custom_clouddetails')) ->addChild(Lang::trans('custom_clouddetails_1'), array( 'label' => Lang::trans('custom_clouddetails_1'), 'uri' => 'cloud_1.php', 'order' => '10', )); } }); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild(Lang::trans('custom_clouddetails')))) { $primaryNavbar->getChild(Lang::trans('custom_clouddetails')) ->addChild(Lang::trans('custom_clouddetails_2'), array( 'label' => Lang::trans('custom_clouddetails_2'), 'uri' => 'custom_clouddetails_2.php', 'order' => '20', )); add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild(Lang::trans('custom_clouddetails')))) { $primaryNavbar->getChild(Lang::trans('custom_clouddetails')) ->addChild(Lang::trans('custom_clouddetails_3'), array( 'label' => Lang::trans('custom_clouddetails_3'), 'uri' => 'custom_clouddetails_3.php', 'order' => '30', )); - - - Updated - - - Sorry, I solved it. I put them all together and then it works Edited May 12, 2016 by paperweight added some more info 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 12, 2016 Share Posted May 12, 2016 Sorry, I solved it. I put them all together and then it works i'm glad you solved it! when I saw your code I initially had two thoughts... 1. why are they 4 separate hooks! 2. why are you using language translations in the names (get and add) of the children (or parent)? addChild(Lang::trans('custom_clouddetails')) I suppose it would work, but child names are for internal use only - yes, they'd be used externally as a label if you weren't defining one, but you are... so seems like an unnecessary complication to me. it's possible that if the client was using a language where these translations did not exist, the hooks could cause an error - personally, i'd just give them defined names in English (or any other language) so they would be easier to reference... getChild('Cloud Details')) 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.