something not so global in Global Content Blocks [SOLVED]

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
Edwin_IandD
Forum Members
Forum Members
Posts: 80
Joined: Thu Aug 12, 2010 2:27 pm

something not so global in Global Content Blocks [SOLVED]

Post by Edwin_IandD »

I am using a Global Content Block for my footer on my homepage. Works wonders, however, I would like to use a counter in the footer, but only on the home page.

Does anybody has any ideas on how to do this?

Many thanks,

Edwin
Last edited by Edwin_IandD on Fri May 06, 2011 2:58 pm, edited 1 time in total.
User avatar
polodesign
Forum Members
Forum Members
Posts: 55
Joined: Sun Jan 03, 2010 1:58 am

Re: something not so global in Global Content Blocks

Post by polodesign »

Hi Edwin_IandD,

I just tested this and it works.

1. Create a new global content block containing the code for your counter.

2. Put {get_template_vars} into your template then go to the page where you want the counter to appear. From the list of variables, find the one that corresponds to the page alias for that page.

3. Using that variable, create an {if} statement that calls the new global content block and place that in your template where you want the counter to appear. To ensure that it's working correctly, check another page that uses the same template to make sure your counter doesn't show up where you don't want it to.

When I'm trying to figure out how work with templates and find out what variables are available to me, I often go back and check this post on Calguy's blog: http://calguy1000.com/Blogs/12/60/basic ... kills.html

Hope that helps.

Regards,
Penny
Edwin_IandD
Forum Members
Forum Members
Posts: 80
Joined: Thu Aug 12, 2010 2:27 pm

Re: something not so global in Global Content Blocks

Post by Edwin_IandD »

Hello Penny,

Thank you very much.

This was the solution:
I placed the following {if} statement inside my footer Global Content Block:
{if $page_alias=='home'}{global_content name='counter'}{/if}

Nothing happens except on the home page, where it shows the counter.

This even works if you put this in the Global Content Block, not just in the template.
That way you can keep all the layout code in the main Global Content Block and only have the line of text including smarty-tags for the counter in the Global Content Block called 'counter'. Which means you can place it anywhere in your layout...

Many thanks!
User avatar
polodesign
Forum Members
Forum Members
Posts: 55
Joined: Sun Jan 03, 2010 1:58 am

Re: something not so global in Global Content Blocks

Post by polodesign »

I'm glad to hear it worked and that you went further to put it all in the GCB.

Please take a moment to edit the Subject line in your first post to add [SOLVED] so others will see this solution.

Cheers!
Post Reply

Return to “CMSMS Core”