Sybille Posted June 10, 2016 Share Posted June 10, 2016 Hi, I'm new to WHMCS and I would really appreciate your help. I have a similar question as in threat “Changing-Breadcrumbs” http://forum.whmcs.com/showthread.php?2286-Changing-Breadcrumbs It would be useful if the breadcrumb nav would display EVERY step of the Navigation. And the menu "Support" is not needed in the nav. at the moment the navigation displays: Support -> customer center -> my Domains I would prefere: customer center -> menu -> submenu for example: customer center -> Domain -> my Domains I really appreciate your help. Thanks in advanced. Link to comment Share on other sites More sharing options...
sentq Posted June 10, 2016 Share Posted June 10, 2016 using this ActionHook you can change order of breadcrumb or modify what's displayed there Link to comment Share on other sites More sharing options...
Sybille Posted June 12, 2016 Author Share Posted June 12, 2016 Hi Sentq Thanks for your reply. Because I'm new to WHMCS I would really appreciate if you could give me some more details. I just created the hook as followed. But I don't know what I have to fill in, because the values are depending on the menu the user clicked at and I don't know the variable for the menu nor the submenu are. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPage', 1, function(MenuItem $[b]???[/b]) { $return = array(); $return = array("[b]field1[/b]" => "[b]value1[/b]", "[b]field2[/b]" => "[b]value2[/b]"); return $return; }); Link to comment Share on other sites More sharing options...
sentq Posted June 12, 2016 Share Posted June 12, 2016 Sybille, Create new PHP file inside /includes/hooks/ directory, copy the following code inside it <?php add_hook("ClientAreaPage", 1, function($vars){ # Get Current Breadcrumb & Apply Changes To foreach ($vars['breadcrumb'] as $index => $item){ $item['link']; // Link $item['label']; // Title # Example Change First Link Title To "Dashboard" if ($index==0){ $vars['breadcrumb'][$index]['label'] = "Dashboard"; } } # Return Updated Breadcrumb To Smarty return array("breadcrumb" => $vars['breadcrumb']); }); this should give you basic idea of how you can apply changes to breadcrumbs Link to comment Share on other sites More sharing options...
Sybille Posted June 13, 2016 Author Share Posted June 13, 2016 Hi Sentq, Thanks for your script. With it it's possible to add a new fix menu item to the breadcrumb. I'd like to add the main menu (e.g. Services, Billing, Domain, Support and so on) as well in to the breadcrumb (of course without link, because neither of the main menu has an own page). The user should be able to see, which main menu he have clicked on to get to the sub menu he is at the moment. for example: - customer center -> Domain -> my Domains - customer center -> Billing -> my Quote Perhaps my explanation is a little bit complicated - sorry for that. greets Link to comment Share on other sites More sharing options...
brian! Posted June 13, 2016 Share Posted June 13, 2016 (edited) I think the simplest way to do that would require you to define which submenu items belong to which "menu" - the hook won't know unless you tell it! if your site was only using one language, then you could probably have coded this to react to label values - you still can if you use language strings in the arrays, but then you'd potentially run into issues if you had changed the labels on these submenus via hooks... therefore, it's easier to use the links which should always be the same for all languages... although weirdly, i've had to make an exception to that because some of the support pages were not responding correctly to the link values... not sure why, it's probably something obvious i'm missing, but it should work ok with labels... though you might want to test it thoroughly. <?php add_hook("ClientAreaPage", 1, function($vars){ $domains = array('clientarea.php?action=domains'); $billing = array('clientarea.php?action=invoices','clientarea.php?action=quotes','clientarea.php?action=masspay&all=true#','clientarea.php?action=addfunds'); $services = array('clientarea.php?action=products'); $tickets = array('supporttickets.php'); $myaccount = array('clientarea.php?action=details','clientarea.php?action=contacts','clientarea.php?action=changepw','clientarea.php?action=security','clientarea.php?action=emails'); $support = array(Lang::trans('knowledgebasetitle'),Lang::trans('announcementstitle'),Lang::trans('downloadstitle'),Lang::trans('serverstatustitle')); # Get Current Breadcrumb & Apply Changes To foreach ($vars['breadcrumb'] as $index => $item){ $item['link']; // Link $item['label']; // Title # Example Change First Link Title To "Customer Center" if ($index==0){ $vars['breadcrumb'][$index]['label'] = "Customer Center"; } # Change Other Labels To Their Parent Menu Array Label if (in_array($vars['breadcrumb'][$index]['link'],$domains)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navdomains'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$billing)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navbilling'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$services)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navservices'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$tickets)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navsupport'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$myaccount)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('myaccount'); break; } elseif (in_array($vars['breadcrumb'][$index]['label'],$support)) { $newentry = array("link"=>"","label"=>Lang::trans('navsupport')); array_splice($vars['breadcrumb'],$index,0,array($newentry)); break; } } # Return Updated Breadcrumb To Smarty return array("breadcrumb" => $vars['breadcrumb']); }); that would work in the client area by renaming both the initial breadcrumb to "Customer Center", and renaming "Client Area" to the menu label (as defined in the hook). where the above method doesn't quite work is on some of the support pages (kb, network status etc) because they don't include "Client Area" in the breadcrumb array, and so there is nothing to rename... for these submenus, i've inserted the appropriate(?) menu ('Support') into the array and ensured that it's only added once. I was working from memory on the CA links, so you should probably go through the client area as I have likely missed some out - if so, then you either need to assign them to an existing array, or create a new array and add an appropriate elseif block of code in the hook. Edited June 14, 2016 by brian! Link to comment Share on other sites More sharing options...
Sybille Posted June 15, 2016 Author Share Posted June 15, 2016 Hi Brian, Thanks for the script. I'd worked almost fine. But I'm still working on the fine tuning. The name of the main menu (e.g. Domain, billing, Support and so on) links in the breadcrumb to home / custom center, but I would prefer, that the name of the menu is just displayed but without a link function. Home (link) / Domain (without link) / My Domains (without link) Because I'm still working on that, I haven't answered till now - I'm sorry. Link to comment Share on other sites More sharing options...
brian! Posted June 16, 2016 Share Posted June 16, 2016 the quick solution to that would be to modify templates/six(or your custom)/includes/breadcrumb.tpl and change... <ol class="breadcrumb"> {foreach $breadcrumb as $item} <li{if $item@last} class="active"{/if}> {if !$item@last}<a href="{$item.link}">{/if} {$item.label} {if !$item@last}</a>{/if} </li> {/foreach} </ol> to... <ol class="breadcrumb"> {foreach $breadcrumb as $item} <li{if !$item@first} class="active"{/if}> {if $item@first}<a href="{$item.link}">{/if} {$item.label} {if $item@first}</a>{/if} </li> {/foreach} </ol> that should link the first breadcrumb, and not the others... there will possibly be a way to do it in the hook, but i'm having a few days away with friends to celebrate my birthday this weekend, so I probably won't be back until next week. Link to comment Share on other sites More sharing options...
Sybille Posted June 16, 2016 Author Share Posted June 16, 2016 That helped a lot I've changed the script a little bit, because I'd liked to remove the "Support". It worked fine, but now there is a space where "Support" was before. <ol class="breadcrumb"> {foreach $breadcrumb[b]|replace:'Support':'' as $item[/b]} <li{if !$item@first} class="active"{/if}> {if $item@first}<a href="{$item.link}">{/if} {$item.label} {if $item@first}</a>{/if} </li> {/foreach} </ol> Your reply doesn't rush. I don't congratulate now, because to congratulate in advanced means bad luck. Enjoy your time and have an awesome time with your friends. Have a great trip! Link to comment Share on other sites More sharing options...
brian! Posted June 24, 2016 Share Posted June 24, 2016 you can't throw a replace into the middle of a foreach loop - though even if you could, it would only work for English! the solution would be to first leave the breadcrumb template changes as they were... <ol class="breadcrumb"> {foreach $breadcrumb as $item} <li{if !$item@first} class="active"{/if}> {if $item@first}<a href="{$item.link}">{/if} {$item.label} {if $item@first}</a>{/if} </li> {/foreach} </ol> and then in the hook, simply modify the arrays and remove any URLs that you don't want to add "Support" to... $tickets = array('supporttickets.php'); $myaccount = array('clientarea.php?action=details','clientarea.php?action=contacts','clientarea.php?action=changepw','clientarea.php?action=security','clientarea.php?action=emails'); $support = array(Lang::trans('knowledgebasetitle'),Lang::trans('announcementstitle'),Lang::trans('downloadstitle'),Lang::trans('serverstatustitle')); Link to comment Share on other sites More sharing options...
Sybille Posted June 28, 2016 Author Share Posted June 28, 2016 I hope you have had a incredible trip. Thanks for your reply. In this case I better leave the breadcrumbs as it was. Even though many thanks!!! Link to comment Share on other sites More sharing options...
araxy Posted January 25, 2018 Share Posted January 25, 2018 On 13/06/2016 at 5:25 PM, brian! said: I think the simplest way to do that would require you to define which submenu items belong to which "menu" - the hook won't know unless you tell it! if your site was only using one language, then you could probably have coded this to react to label values - you still can if you use language strings in the arrays, but then you'd potentially run into issues if you had changed the labels on these submenus via hooks... therefore, it's easier to use the links which should always be the same for all languages... although weirdly, i've had to make an exception to that because some of the support pages were not responding correctly to the link values... not sure why, it's probably something obvious i'm missing, but it should work ok with labels... though you might want to test it thoroughly. <?php add_hook("ClientAreaPage", 1, function($vars){ $domains = array('clientarea.php?action=domains'); $billing = array('clientarea.php?action=invoices','clientarea.php?action=quotes','clientarea.php?action=masspay&all=true#','clientarea.php?action=addfunds'); $services = array('clientarea.php?action=products'); $tickets = array('supporttickets.php'); $myaccount = array('clientarea.php?action=details','clientarea.php?action=contacts','clientarea.php?action=changepw','clientarea.php?action=security','clientarea.php?action=emails'); $support = array(Lang::trans('knowledgebasetitle'),Lang::trans('announcementstitle'),Lang::trans('downloadstitle'),Lang::trans('serverstatustitle')); # Get Current Breadcrumb & Apply Changes To foreach ($vars['breadcrumb'] as $index => $item){ $item['link']; // Link $item['label']; // Title # Example Change First Link Title To "Customer Center" if ($index==0){ $vars['breadcrumb'][$index]['label'] = "Customer Center"; } # Change Other Labels To Their Parent Menu Array Label if (in_array($vars['breadcrumb'][$index]['link'],$domains)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navdomains'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$billing)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navbilling'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$services)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navservices'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$tickets)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('navsupport'); } elseif (in_array($vars['breadcrumb'][$index]['link'],$myaccount)) { $vars['breadcrumb'][$index-1]['label'] = Lang::trans('myaccount'); break; } elseif (in_array($vars['breadcrumb'][$index]['label'],$support)) { $newentry = array("link"=>"","label"=>Lang::trans('navsupport')); array_splice($vars['breadcrumb'],$index,0,array($newentry)); break; } } # Return Updated Breadcrumb To Smarty return array("breadcrumb" => $vars['breadcrumb']); }); that would work in the client area by renaming both the initial breadcrumb to "Customer Center", and renaming "Client Area" to the menu label (as defined in the hook). where the above method doesn't quite work is on some of the support pages (kb, network status etc) because they don't include "Client Area" in the breadcrumb array, and so there is nothing to rename... for these submenus, i've inserted the appropriate(?) menu ('Support') into the array and ensured that it's only added once. I was working from memory on the CA links, so you should probably go through the client area as I have likely missed some out - if so, then you either need to assign them to an existing array, or create a new array and add an appropriate elseif block of code in the hook. Hello, I saw your publication and tested for a similar problem. But that does not change my breadcrumb, does it still work on the latest version of WHMCS? Thank you in advance Cordially Link to comment Share on other sites More sharing options...
sentq Posted January 25, 2018 Share Posted January 25, 2018 in which page(s) you're trying to change the breadcrumbs exactly? Link to comment Share on other sites More sharing options...
araxy Posted January 25, 2018 Share Posted January 25, 2018 52 minutes ago, sentq said: dans quelle (s) page (s) vous essayez de changer exactement la miette de pain? Hello, I try in several pages: - knowledge bases - server states - network problem - downloads - contact - support request - open a request For example for knowledge base I have: Home (index.php)> KnowledgeBase (Knowledgebase.php) I would like to replace for all these pages the links present in the breadcrumbs because I have done rewriting for French people. And I would like change : Home (index.php) to Aide (/aide/) I hope I have been accurate thank you in advance cordially Link to comment Share on other sites More sharing options...
araxy Posted January 27, 2018 Share Posted January 27, 2018 Nobody knows ? : / Link to comment Share on other sites More sharing options...
sentq Posted January 29, 2018 Share Posted January 29, 2018 in what version/page it didn't work, I've tested the Brian's code and it did works in WHMCS v7.4.1? Link to comment Share on other sites More sharing options...
Recommended Posts