Jump to content

Nav Bar Issue


cseamiya

Recommended Posts

3 hours ago, cseamiya said:

I don't want to show the navbar to non-registered customer. when a customer will login the login navbar will show. but i want to hide the prelogin navigation bar. what should i do?

Chris' answer is correct in that using a hook to modify the menu array would be the official solution to this.

however, I would suggest that modifying /templates/six (or custom)/header.tpl and changing at line ~ 119 from

<ul class="nav navbar-nav">
	{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}
</ul>

<ul class="nav navbar-nav navbar-right">
	{include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar}
</ul>

to...

<ul class="nav navbar-nav">
	{if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if}
</ul>

<ul class="nav navbar-nav navbar-right">
	{include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar}
</ul>

.. would achieve the same desired effect without the hassle to writing the hook to only modify the menu... the above will only show the Primary menu (left-hand side) to logged in clients, the Secondary menu (right hand side) would be shown to everyone (though you could repeat the change and hide the Secondary menu in the same way if you wanted to).

hHvXGOl.png

the downside doing this over using a hook is that you'll have to do repeat the code change after every WHMCS update - but there's usually only a handful of updates per year, so shouldn't be too big an issue. thanks.png

Link to comment
Share on other sites

4 hours ago, cseamiya said:

one more thing i want to change this account button from right side also.

"change" in what sense? if you just want to remove it (as per primary), then it's another {if} statement as shown above... if you want to remove.edit.add items in that menu, then that would need a hook.

On 22/10/2018 at 13:52, cseamiya said:

Thanks, but if i want to remove 2 or menu items. should i create more hooks for each menu item

one hook can remove multiple items from the menu... it's going to be simpler for you to have the navbar hooks in one file so that you can see what is going on in ine place... if you have them in multiple files, unless you code them all correctly, you may run into errors.

Link to comment
Share on other sites

15 minutes ago, brian! said:

"change" in what sense? if you just want to remove it (as per primary), then it's another {if} statement as shown above... if you want to remove.edit.add items in that menu, then that would need a hook.

i want to remove it from primary nav bar. where the {if} will be place.

this is my current primary navbar:  {if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if}

Link to comment
Share on other sites

On 24/10/2018 at 13:50, cseamiya said:

i want to remove it from primary nav bar. where the {if} will be place.

just for the avoidance of any confusion - the primary navbar is on the LEFT <<< (RED BOX).. and the secondary navbar is on the RIGHT >>> (YELLOW BOX)...

gZvkUs6.jpg

if you wanted to hide BOTH PRIMARY and SECONDARY navbars for non-logged in users, you would use...

<ul class="nav navbar-nav">
	{if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if}
</ul>

<ul class="nav navbar-nav navbar-right">
	{if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar}{/if}
</ul>
4 hours ago, cseamiya said:

Hi, i want to only show home and contact us nav bar in primary navbar. how can i?

if you now want to show the navbar to non-logged in users, then you can ignore the above {if} statements...

to remove the other children, and just leave the two links you mention, then you would either need to use an action hook to remove them, or css (in /templates/six (or custom)/css/custom.css

#Primary_Navbar-Store,
#Primary_Navbar-Announcements,
#Primary_Navbar-Knowledgebase,
#Primary_Navbar-Network_Status,
#Primary_Navbar-Affiliates
{ display: none; }

W9heOxJ.jpg

4 hours ago, cseamiya said:

and can i change the name from home to dashboard in secondary navbar?

if you mean the "Home" above, that's in the PRIMARY navbar, not the SECONDARY...

to change a label, you have two options - using an action hook, or if it's a default WHMCS label, you can use Language Overrides.

remember with language overrides, that you should never directly edit the existing language files in the /lang/ folder... and you will need to use an override file for each language you want to add your custom translations to.

$_LANG['clientareanavhome'] = "Home";
$_LANG['clientareanavhome'] = "Dashboard";

1flbeUn.jpg

Link to comment
Share on other sites

17 hours ago, cseamiya said:

sorry, got it, and thanks for your effort. but i am talking about after login there is navbar, and there  when a user click on home it will take him to clientarea, i want to change that name to dashboard.

then you'll need an action hook - in the example below, all languages will use 'Dashboard' (if you need it multilingual, you'd need to create Language Overrides and change the hook to use them instead)...

<?php

# Change Home Label To Dashboard For Clients Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if ($client && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setLabel('Dashboard');
	}	
});
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