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
something not so global in Global Content Blocks [SOLVED]
-
- Forum Members
- Posts: 80
- Joined: Thu Aug 12, 2010 2:27 pm
something not so global in Global Content Blocks [SOLVED]
Last edited by Edwin_IandD on Fri May 06, 2011 2:58 pm, edited 1 time in total.
- polodesign
- Forum Members
- Posts: 55
- Joined: Sun Jan 03, 2010 1:58 am
Re: something not so global in Global Content Blocks
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
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
-
- Forum Members
- Posts: 80
- Joined: Thu Aug 12, 2010 2:27 pm
Re: something not so global in Global Content Blocks
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!
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!
- polodesign
- Forum Members
- Posts: 55
- Joined: Sun Jan 03, 2010 1:58 am
Re: something not so global in Global Content Blocks
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!
Please take a moment to edit the Subject line in your first post to add [SOLVED] so others will see this solution.
Cheers!