Jump to content

remove sidebar from home page, market connect and product pages


Recommended Posts

Ive seen how to add in a hook to hide the left sidebar sections on various pages but id like to hide it from the main market connect pages, the initial page for each product group, custom pages and the home page.

Now i know on the custom pages thats easy... but i cannto for the life of me see how to hide it on market connect and the home page but not the client area...

Im just trying to make the main public pages full width with no left sidebar.. instead of adding in a 3rd party theme system to the install.

Link to comment
Share on other sites

Hi Steve,

5 hours ago, theozsnowman said:

Ive seen how to add in a hook to hide the left sidebar sections on various pages but id like to hide it from the main market connect pages, the initial page for each product group, custom pages and the home page.

there would be two generic answers that I could give to that - the first being that the Store (MC) sales pages don't natively contain sidebars; the second being to write a hook that nukes all sidebars (which i've previously posted, but i'll modify it for you to specifically nuke the Store sidebars)...

<?php

# Store Nuclear Sidebar Removal
# Written by brian!

function nuclear_remove_Sidebars_hook($vars) {
	
	GLOBAL $smarty;
	$template = $smarty->getVariable('template');
	$templatefile = $smarty->getVariable('templatefile');
	if (strpos($templatefile, 'store/') !== false) {
		$primarySidebar = Menu::primarySidebar();
		$primarykids = $primarySidebar->getChildren();
		$secondarySidebar = Menu::secondarySidebar();
		$secondarykids = $secondarySidebar->getChildren();
		foreach ($primarykids as $Sidebar) {
			$primarySidebar->removeChild($Sidebar);
		}
		foreach ($secondarykids as $Sidebar) {
			$secondarySidebar->removeChild($Sidebar);
		}
	}
}	
add_hook("ClientAreaSidebars",2,"nuclear_remove_Sidebars_hook");
5 hours ago, theozsnowman said:

Now i know on the custom pages thats easy... but i cannto for the life of me see how to hide it on market connect and the home page but not the client area...

which takes me to the third answer, and the one I think should be correct in your circumstance - looking at your site, the only sidebar i'm seeing (on those pages) is a Social Media sidebar... i'm assuming you've added that based on the sidebar example in the docs.

https://docs.whmcs.com/Editing_Client_Area_Menus#Add_a_social_media_panel_to_the_end_of_the_sidebar

that being the case, and as I don't really like the idea of using two hooks - one to create a sidebar on all pages and then a second hook to remove it on certain pages, it should be simpler to just modify the original hook to only work on certain pages or templates.

<?php

# Social Media Sidebar (Curtailed) Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
	
	GLOBAL $smarty;
	//$client = Menu::context('client');
	$validpages = array("clientarea","supporttickets","submitticket");
	$validtemplates = array("announcements");
	$filename = $smarty->getVariable('filename');
	$templatefile = $smarty->getVariable('templatefile');
	if (in_array($filename,$validpages) || in_array($templatefile,$validtemplates)) {
		$secondarySidebar->addChild('social-media', array('label' => 'Social Media', 'uri' => '#', 'icon' => 'fas fa-thumbs-up',));
		$socialMediaPanel = $secondarySidebar->getChild('social-media');
		$socialMediaPanel->moveToBack();
		$socialMediaPanel->addChild('facebook-link', array('uri' => 'https://facebook.com/our-great-company', 'label' => 'Like us on Facebook!', 'order' => 1, 'icon' => 'fab fa-facebook-f fa-fw',));
		$socialMediaPanel->addChild('twitter-link', array('uri' => 'https://twitter.com/ourgreatcompany', 'label' => 'Follow us on Twitter!', 'order' => 2, 'icon' => 'fab fa-twitter fa-fw',));
	}
});

which limits the sidebar to be only shown on a valid page or template - in the above example, in the client area, supporttickets, submitticket or the announcements page... just to add a little zest to your life, how you determine whether to use the filename or templatename is dictated by the Friendly URL settings.. e.g whether you're accessing it directly, or via index.php etc.

all that said, seeing as you appear to be using Social Media Manager addon to add the social links to the footer of your page, i'm not really sure if you have nay need for this sidebar hook too ?

btw - there is an error in the footer output...

zUxRaSf.png

which I suspect is caused by an outdated TawkTo script (TT isn't showing either).

Link to comment
Share on other sites

5 hours ago, brian! said:

Hi Steve,

there would be two generic answers that I could give to that - the first being that the Store (MC) sales pages don't natively contain sidebars; the second being to write a hook that nukes all sidebars (which i've previously posted, but i'll modify it for you to specifically nuke the Store sidebars)...


<?php

# Store Nuclear Sidebar Removal
# Written by brian!

function nuclear_remove_Sidebars_hook($vars) {
	
	GLOBAL $smarty;
	$template = $smarty->getVariable('template');
	$templatefile = $smarty->getVariable('templatefile');
	if (strpos($templatefile, 'store/') !== false) {
		$primarySidebar = Menu::primarySidebar();
		$primarykids = $primarySidebar->getChildren();
		$secondarySidebar = Menu::secondarySidebar();
		$secondarykids = $secondarySidebar->getChildren();
		foreach ($primarykids as $Sidebar) {
			$primarySidebar->removeChild($Sidebar);
		}
		foreach ($secondarykids as $Sidebar) {
			$secondarySidebar->removeChild($Sidebar);
		}
	}
}	
add_hook("ClientAreaSidebars",2,"nuclear_remove_Sidebars_hook");

which takes me to the third answer, and the one I think should be correct in your circumstance - looking at your site, the only sidebar i'm seeing (on those pages) is a Social Media sidebar... i'm assuming you've added that based on the sidebar example in the docs.

https://docs.whmcs.com/Editing_Client_Area_Menus#Add_a_social_media_panel_to_the_end_of_the_sidebar

that being the case, and as I don't really like the idea of using two hooks - one to create a sidebar on all pages and then a second hook to remove it on certain pages, it should be simpler to just modify the original hook to only work on certain pages or templates.


<?php

# Social Media Sidebar (Curtailed) Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
	
	GLOBAL $smarty;
	//$client = Menu::context('client');
	$validpages = array("clientarea","supporttickets","submitticket");
	$validtemplates = array("announcements");
	$filename = $smarty->getVariable('filename');
	$templatefile = $smarty->getVariable('templatefile');
	if (in_array($filename,$validpages) || in_array($templatefile,$validtemplates)) {
		$secondarySidebar->addChild('social-media', array('label' => 'Social Media', 'uri' => '#', 'icon' => 'fas fa-thumbs-up',));
		$socialMediaPanel = $secondarySidebar->getChild('social-media');
		$socialMediaPanel->moveToBack();
		$socialMediaPanel->addChild('facebook-link', array('uri' => 'https://facebook.com/our-great-company', 'label' => 'Like us on Facebook!', 'order' => 1, 'icon' => 'fab fa-facebook-f fa-fw',));
		$socialMediaPanel->addChild('twitter-link', array('uri' => 'https://twitter.com/ourgreatcompany', 'label' => 'Follow us on Twitter!', 'order' => 2, 'icon' => 'fab fa-twitter fa-fw',));
	}
});

which limits the sidebar to be only shown on a valid page or template - in the above example, in the client area, supporttickets, submitticket or the announcements page... just to add a little zest to your life, how you determine whether to use the filename or templatename is dictated by the Friendly URL settings.. e.g whether you're accessing it directly, or via index.php etc.

all that said, seeing as you appear to be using Social Media Manager addon to add the social links to the footer of your page, i'm not really sure if you have nay need for this sidebar hook too ?

btw - there is an error in the footer output...

zUxRaSf.png

which I suspect is caused by an outdated TawkTo script (TT isn't showing either).

I wasn't aware of this module - so that's another thing added to whmcs 8.x that a 3rd party dev made  🤣

But I can confirm that is tawk needing a little bit of a tweak! I can't for the life of me remember what causes it, but I can break it and let you know if you don't sort it! 

Link to comment
Share on other sites

One further small question,,,...

 

on pages such as cart.php?a=add&domain=register and cart.php?a=add&domain=transfer  how do i hide the sidebar on these as well... just on that initial part of the function?

is it going to be essentially the same code but changing the line:

if (strpos($templatefile, 'store/') !== false) {

to

if (strpos($templatefile, 'orderforms/') !== false) {

or is it something different when it comes to hiding it on cart.php?

Link to comment
Share on other sites

12 hours ago, theozsnowman said:

on pages such as cart.php?a=add&domain=register and cart.php?a=add&domain=transfer  how do i hide the sidebar on these as well... just on that initial part of the function?

all sidebars or just the social media one? i'm not seeing the social media one on the site, so I assume it's not that... or you've sorted it yourself.

if on those pages, domain transfer / register, you wanted to remove *all* sidebars, then emptying the sidebar array doesn't work (well it gets rid of the sidebars, but leaves a gap on the left - that's a bug that's been there since v6)...

<?php

# Cart Sidebar Removal / Resizing v8.1 Hook
# Written by brian!

function cart_remove_sidebars_hook($vars)
{	
	$validtemplates = array("domainregister","domaintransfer");
	if ($vars['inShoppingCart'] && !in_array($vars['templatefile'],$validtemplates)) {
		$head_return = "<style>#order-standard_cart .cart-body { width:100% !important; }
		.cart-sidebar {display: none;}</style>";
		return $head_return;
	}
}
add_hook("ClientAreaHeaderOutput",1,"cart_remove_sidebars_hook");

also, you might also want to take a look at your TLD list - hundreds of them don't have any pricing, and lots of them you definitely wouldn't be allowed to register, let alone search - the obvious one that stuck out to me being police.uk (but ac, mod, nhs, nic, and sch.uk would be the same.) 👮‍♂️

Link to comment
Share on other sites

thanks for the tips... and yes i removed the sidebar completely from the pages i wanted it gone from it was just the cart ones i couldn't work out..

as for the domain names... im trying to get my head around why thats happening. I did have the Domain Orders Extended module installed, but it never behaved correctly so went back to the normal setup... perhaps something is a bit screwy because of this...

 

 

Link to comment
Share on other sites

hrrrm ok i added the hook to remove the sidebar as you suggested  but im finding that its still there...

an example: https://accounts.snowtech.com.au/cart.php?a=add&domain=register&query=snowman56.com.au

the rest of the cart process hides the sidebar...without issue

 

 

On 6/12/2021 at 1:40 AM, brian! said:

all sidebars or just the social media one? i'm not seeing the social media one on the site, so I assume it's not that... or you've sorted it yourself.

if on those pages, domain transfer / register, you wanted to remove *all* sidebars, then emptying the sidebar array doesn't work (well it gets rid of the sidebars, but leaves a gap on the left - that's a bug that's been there since v6)...


<?php

# Cart Sidebar Removal / Resizing v8.1 Hook
# Written by brian!

function cart_remove_sidebars_hook($vars)
{	
	$validtemplates = array("domainregister","domaintransfer");
	if ($vars['inShoppingCart'] && !in_array($vars['templatefile'],$validtemplates)) {
		$head_return = "<style>#order-standard_cart .cart-body { width:100% !important; }
		.cart-sidebar {display: none;}</style>";
		return $head_return;
	}
}
add_hook("ClientAreaHeaderOutput",1,"cart_remove_sidebars_hook");

also, you might also want to take a look at your TLD list - hundreds of them don't have any pricing, and lots of them you definitely wouldn't be allowed to register, let alone search - the obvious one that stuck out to me being police.uk (but ac, mod, nhs, nic, and sch.uk would be the same.) 👮‍♂️

 

Capture.JPG

Link to comment
Share on other sites

12 hours ago, theozsnowman said:

as for the domain names... im trying to get my head around why thats happening. I did have the Domain Orders Extended module installed, but it never behaved correctly so went back to the normal setup... perhaps something is a bit screwy because of this...

it's strange that some of those TLDs were on any list... reminded me of the old v6 days when WHMCS found a list of TLDs, added them to the database and didn't even bother to check if some of therm were a) valid and/or b) brands (and therefore not available for public  registration).

12 hours ago, theozsnowman said:

the rest of the cart process hides the sidebar...without issue

I think that I probably didn't emphasise above the importance of the $validtemplates array and how it defines which templates will be shown with sidebars....

On 25/01/2021 at 16:07, brian! said:

the only line you should need to change is the $validtemplates array which defines which cart templates (if any) should show the sidebars.

if you're saying that you don't want any of the cart pages to include any sidebars, then it's just a case of removing the registration/transfer templates from the array - the quickest way being to either comment that line or or remove it entirely.

	//$validtemplates = array("domainregister","domaintransfer");	
Link to comment
Share on other sites

17 hours ago, theozsnowman said:

i was thinking backwards in that the valid templates were the ones to hide the sidebar on, not show it on...

in fairness, i've used $validtemplates to mean either valid or invalid depending on the particular hook, so that might have caused some unnecessary confusion.

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