Hopefully I'm in the right place to ask this.
I'm trying to figure out how to include a global content block on a specific block of page and its subpages. I'm hoping to not do it in the wysywig, so it doesn't get deleted.
I tried dropping the global tag into a couple spots in the page options section, but nothing appeared.
page-specific global content
-
- Forum Members
- Posts: 34
- Joined: Tue Oct 08, 2013 8:29 pm
Re: page-specific global content
Can you be more specific in what exactly you are trying to do?
Re: page-specific global content
Have a look at the page_attr tagturpentyne wrote:Hopefully I'm in the right place to ask this.
I'm trying to figure out how to include a global content block on a specific block of page and its subpages. I'm hoping to not do it in the wysywig, so it doesn't get deleted.
I tried dropping the global tag into a couple spots in the page options section, but nothing appeared.
Possibly you need to use {eval} tag when you're dropping the tag into the Extra Page Attribute of Page options
not tested:
Code: Select all
{* assign contents of page options 'Extra Page Attribute 1' to variable foo *}
{page_attr key='extra1' assign='foo'}
{* if $foo is not false/empty *}
{if $foo}
{* evaluate contents of $foo *}
{eval var=$foo}
{/if}
Re: page-specific global content
If what you are trying to do is to insert a global content block into a page that cannot be edited/removed by someone editing the actual page, the place to call it is in the template itself.turpentyne wrote:Hopefully I'm in the right place to ask this.
I'm trying to figure out how to include a global content block on a specific block of page and its subpages. I'm hoping to not do it in the wysywig, so it doesn't get deleted.
I tried dropping the global tag into a couple spots in the page options section, but nothing appeared.
The upside is the global content block is protected from users who edit the page. Also the block can appear exactly where you need it in the markup.
The downside is that the block's content will appear in all pages that use that template. If it should only appear on specific pages, you can wrap some conditional logic based on $page_alias around the call to the global content block. Something like this can work:
Code: Select all
{if $page_alias = 'my_page'}{global_content name="blah"}{/if}
Code: Select all
{content block="beforegc" title="Content before"}
{if $page_alias = 'my_page'}{global_content name="blah"}{/if}
{content block="aftergc" title="Content after"}
Hope that help.
-S