Jump to content

Custom Page with skipMainBodyContainer


zmen

Recommended Posts

Hello. I want to create custom page without breadcrumb and container (col-xs-12). Because i have elements with full width.

I see val $skipMainBodyContainer, but how i can use it on custom page?

Create page with this: https://developers.whmcs.com/advanced/creating-pages/

Link to comment
Share on other sites

header.tpl
 

<section id="main-body">
    <div class="container{if $skipMainBodyContainer}-fluid without-padding{/if}">
        <div class="row">

        {if !$inShoppingCart && ($primarySidebar->hasChildren() || $secondarySidebar->hasChildren())}
            {if $primarySidebar->hasChildren() && !$skipMainBodyContainer}
                <div class="col-md-9 pull-md-right">
                    {include file="$template/includes/pageheader.tpl" title=$displayTitle desc=$tagline showbreadcrumb=true}
                </div>
            {/if}
            <div class="col-md-3 pull-md-left sidebar">
                {include file="$template/includes/sidebar.tpl" sidebar=$primarySidebar}
            </div>
        {/if}
        <!-- Container for main page display content -->
        <div class="{if !$inShoppingCart && ($primarySidebar->hasChildren() || $secondarySidebar->hasChildren())}col-md-9 pull-md-right{else}col-xs-12{/if} main-content">
            {if !$primarySidebar->hasChildren() && !$showingLoginPage && !$inShoppingCart && $templatefile != 'homepage' && !$skipMainBodyContainer}
                {include file="$template/includes/pageheader.tpl" title=$displayTitle desc=$tagline showbreadcrumb=true}
            {/if}

 

Link to comment
Share on other sites

On 09/09/2018 at 10:28, zmen said:

header.tpl

aah - hiding in plain sight.. the little rascal.

if you don't want to add breadcrumbs, then don't define them in the php page...

with regards to full width, you can use the following in header.tpl

{if $filename eq '*custom filename*'}
	{assign skipMainBodyContainer true}
{/if}

and so by implication, you should be able to do the same with a hook... setting the variable in the php file doesn't seem to work though.

Link to comment
Share on other sites

36 minutes ago, brian! said:

aah - hiding in plain sight.. the little rascal.

if you don't want to add breadcrumbs, then don't define them in the php page...

with regards to full width, you can use the following in header.tpl


{if $filename eq '*custom filename*'}
	{assign skipMainBodyContainer true}
{/if}

and so by implication, you should be able to do the same with a hook... setting the variable in the php file doesn't seem to work though.

 I could not do urs example. Just do:

    <div class="container{if $skipMainBodyContainer}-fluid without-padding{/if}{if $templatefile == 'custom_page'}-fluid without-padding{/if}">

But how i must write it to use many page in if or just copy many times this if? 

And i remove pageheader with this:

{if $templatefile != 'custom_page'}
<div class="header-lined">
    <h1>{$title}{if $desc} <small>{$desc}</small>{/if}</h1>
    {if $showbreadcrumb}{include file="$template/includes/breadcrumb.tpl"}{/if}
</div>
{/if}

So the same question (a few pages)

And you say that i can do this with hook. Can you write the example ?

Link to comment
Share on other sites

let's say we create a *very* basic PHP custom page - no sidebars, no login requirement and no breadcrumbs...

<?php
use WHMCS\ClientArea;
define('CLIENTAREA', true);
require __DIR__ . '/init.php';
$ca = new ClientArea();
$ca->setPageTitle('Custom Page');
$ca->initPage();
$ca->setTemplate('custom');
$ca->output();

and then in the custom.tpl template, if we just use some Lorem Ipsum text (with no divs), that would give you the following output...

REZA6aW.png

there is a slight gap where the empty $breadcrumb array is outputting - they'd be a number of ways to fix that... you could pass $breadcrumb=false in header.tpl, or you could modify /includes/breadcrumb.tpl to only output if there are breadcrumbs in the array...

however, if you're going to set the value of $skipMainBodyContainer using a hook on these custom pages, then neither Pagetitle or breadcrumbs will be shown anyway, and so you'll see full-width output...

IvbMCCD.png

and the hook to set custom page(s) full width, would be...

<?php

# Set Selected Custom Pages Full Width Hook
# Written by brian!

function client_custom_pages_hook($vars) {
	$custom_filenames = ['custom','custom2'];
	$filename = $vars['filename'];
	if (in_array($filename,$custom_filenames)) {
		return array("skipMainBodyContainer" => true);
	}
}
add_hook("ClientAreaPage", 1, "client_custom_pages_hook");
?>

so in the above example, custom.php and custom2.php pages would show their content full-width (assuming no sidebars enabled etc)... all other pages, would display as normal.

Link to comment
Share on other sites

  • 1 year later...
On 9/11/2018 at 9:30 PM, brian! said:

let's say we create a *very* basic PHP custom page - no sidebars, no login requirement and no breadcrumbs...


<?php
use WHMCS\ClientArea;
define('CLIENTAREA', true);
require __DIR__ . '/init.php';
$ca = new ClientArea();
$ca->setPageTitle('Custom Page');
$ca->initPage();
$ca->setTemplate('custom');
$ca->output();

and then in the custom.tpl template, if we just use some Lorem Ipsum text (with no divs), that would give you the following output...

REZA6aW.png

there is a slight gap where the empty $breadcrumb array is outputting - they'd be a number of ways to fix that... you could pass $breadcrumb=false in header.tpl, or you could modify /includes/breadcrumb.tpl to only output if there are breadcrumbs in the array...

however, if you're going to set the value of $skipMainBodyContainer using a hook on these custom pages, then neither Pagetitle or breadcrumbs will be shown anyway, and so you'll see full-width output...

IvbMCCD.png

and the hook to set custom page(s) full width, would be...


<?php

# Set Selected Custom Pages Full Width Hook
# Written by brian!

function client_custom_pages_hook($vars) {
	$custom_filenames = ['custom','custom2'];
	$filename = $vars['filename'];
	if (in_array($filename,$custom_filenames)) {
		return array("skipMainBodyContainer" => true);
	}
}
add_hook("ClientAreaPage", 1, "client_custom_pages_hook");
?>

so in the above example, custom.php and custom2.php pages would show their content full-width (assuming no sidebars enabled etc)... all other pages, would display as normal.

Thanks @brian! 

Link to comment
Share on other sites

  • 6 months later...

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