Page 1 of 1
[SOLVED] Exclude a global content block from one page
Posted: Thu Oct 07, 2010 1:16 pm
by SusanN
I've searched and searched for the answer to my question, but I'm not finding the info I need.
How can I exclude a global content block from one page of my site? For example, I have the following in my template:
{global_content name='right-sidebar'}
What do I need to add in order to remove it from one single page?
-------------------------------
Got it:
{if $page_alias != 'page-alias'}
{global_content name='right-sidebar'}
{/if}
Re: [SOLVED] Exclude a global content block from one page
Posted: Fri Nov 05, 2010 4:08 pm
by beherenow_uk
Hi Susan,
How did you get this to exclude a single page? i have a page with alias: /free-trial/ how would this work with this piece of code?
To me, that code looks like a conditional comment for including a GCB, not excluding it?
Cheers
Re: [SOLVED] Exclude a global content block from one page
Posted: Fri Nov 05, 2010 4:24 pm
by Wishbone
Another thing that you can do to get rid of the hard-coded page alias in your solution is to leverage the "Extra Page Attribute 1" field in the options panel when editing the page. For the page that you don't want the right sidebar, you can place "noright" in this field, and use the following in your template:
Code: Select all
{page_attr key='extra1' assign='extra1'}
{if $extra1 != "noright"}
{global_content name='right-sidebar'}
{/if}
With this method, you or your client can easily control the appearance of the right sidebar on any page without having to edit the template. I'm sure that the AdvancedContent module has a better way to do this.
Re: [SOLVED] Exclude a global content block from one page
Posted: Fri Nov 05, 2010 4:25 pm
by Wishbone
beherenow_uk wrote:
How did you get this to exclude a single page? i have a page with alias: /free-trial/ how would this work with this piece of code?
To me, that code looks like a conditional comment for including a GCB, not excluding it?
Just replace 'page-alias' (the second one) with 'free-trial'. It is excluding it because of '!=' .. If it doesn't equal this page, show the sidebar.
Code: Select all
{if $page_alias != 'free-trial'}
{global_content name='right-sidebar'}
{/if}
Re: [SOLVED] Exclude a global content block from one page
Posted: Fri Nov 05, 2010 4:36 pm
by SusanN
Right. I've learned that one recently. The ! means exclude.
Re: [SOLVED] Exclude a global content block from one page
Posted: Fri Nov 05, 2010 4:39 pm
by beherenow_uk
Nice work! This is all good guys, thanks for the response.