Jump to content

Remove Sidebar/Menu on Custom Page


Recommended Posts

Hi, 

I created a custom page using the example in the WHMCS documentation and I want to keep it, I've converted it into my Terms and Conditions and Privacy Policy Pages everything works fine. 

I would like to get rid of the sidebar, I'm using Twenty-one template. I tried a few hooks nothing happened there is the 2 menu item lines at the bottom of the PHP file do i need to use or tweak them into something 

 

Any help would be appreciated . I will insert the php example below

 

<?php

use WHMCS\Authentication\CurrentUser;
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;

define('CLIENTAREA', true);

require __DIR__ . '/init.php';

$ca = new ClientArea();

$ca->setPageTitle('Your Page Title Goes Here');

$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('mypage.php', 'Your Custom Page Name');

$ca->initPage();

//$ca->requireLogin(); // Uncomment this line to require a login to access this page

// To assign variables to the template system use the following syntax.
// These can then be referenced using {$variablename} in the template.

//$ca->assign('variablename', $value);

$currentUser = new CurrentUser();
$authUser = $currentUser->user();

// Check login status
if ($authUser) {

    /**
     * User is logged in - put any code you like here
     *
     * Use the User model to access information about the authenticated User
     */

    $ca->assign('userFullname', $authUser->fullName);


    $selectedClient = $currentUser->client();
    if ($selectedClient) {

        /**
         * If the authenticated User has selected a Client Account to manage,
         * the model will be available - put any code you like here
         */

        $ca->assign(
            'clientInvoiceCount',
            $selectedClient->invoices()->count()
        );
    }

} else {

    // User is not logged in
    $ca->assign('userFullname', 'Guest');

}

/**
 * Set a context for sidebars
 *
 * @link http://docs.whmcs.com/Editing_Client_Area_Menus#Context
 */
//Menu::addContext();

/**
 * Setup the primary and secondary sidebars
 *
 * @link http://docs.whmcs.com/Editing_Client_Area_Menus#Context
 */
Menu::primarySidebar('announcementList');
Menu::secondarySidebar('announcementList');

# Define the template filename to be used without the .tpl extension

$ca->setTemplate('mypage');

$ca->output();

 

Link to comment
Share on other sites

19 hours ago, shanejen said:

I would like to get rid of the sidebar, I'm using Twenty-one template. I tried a few hooks nothing happened there is the 2 menu item lines at the bottom of the PHP file do i need to use or tweak them into something 

you've virtually answered your own question - if you don't want to show sidebars, then don't add them to the custom page, e.g don't include the lines below in your php file...

Menu::primarySidebar('announcementList');
Menu::secondarySidebar('announcementList');

now if the custom page is showing a sidebar that is available to all pages, then you might need a hook to remove it from the custom page - but it doesn't sound like that's the case in your situation.

Link to comment
Share on other sites

Hey Brian,

Thanks for the reply.

I wanted to delete them to be honest but I recalled seeing a comment on another post about removing something,   I think from you saying "You don't remove but you add" and I was unsure if it applied in this case. I've just removed them and the sidebar is gone as you predicted. 🙂 

Much appreciated  

 

Link to comment
Share on other sites

@brian! 

I'm confident this is not the way to remove the sidebars when it comes to the product/cart/checkout pages?

I tried the CSS Display/ Visibility and got the empty space or the remaining content moved to the left result. Could you point me in the right direction please I'm using twenty-one temp all the hooks seem to be for Six or I can't find the hook which I'm sure is written

TIA

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