[SOLVED] Exclude a global content block from one page

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
SusanN
Forum Members
Forum Members
Posts: 192
Joined: Wed Jun 13, 2007 5:57 pm

[SOLVED] Exclude a global content block from one page

Post 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}
Last edited by SusanN on Thu Oct 07, 2010 1:43 pm, edited 1 time in total.
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

Re: [SOLVED] Exclude a global content block from one page

Post 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
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: [SOLVED] Exclude a global content block from one page

Post 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.
Last edited by Wishbone on Fri Nov 05, 2010 4:27 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: [SOLVED] Exclude a global content block from one page

Post 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}
Last edited by Wishbone on Fri Nov 05, 2010 4:29 pm, edited 1 time in total.
User avatar
SusanN
Forum Members
Forum Members
Posts: 192
Joined: Wed Jun 13, 2007 5:57 pm

Re: [SOLVED] Exclude a global content block from one page

Post by SusanN »

Right.  I've learned that one recently.  The ! means exclude.
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

Re: [SOLVED] Exclude a global content block from one page

Post by beherenow_uk »

Nice work! This is all good guys, thanks for the response.
Post Reply

Return to “CMSMS Core”