Page 1 of 1

page-specific global content

Posted: Mon Nov 18, 2013 4:18 pm
by turpentyne
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.

Re: page-specific global content

Posted: Tue Nov 19, 2013 11:27 pm
by Wishbone
Can you be more specific in what exactly you are trying to do?

Re: page-specific global content

Posted: Wed Nov 20, 2013 8:51 am
by velden
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.
Have a look at the page_attr tag

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}
EDIT: i would consider another template. Have a look at template inheritance: http://www.i-do-this.com/blog/86/Smarty ... ade-Simple

Re: page-specific global content

Posted: Fri Nov 22, 2013 10:18 pm
by spcherub
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.
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.

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}
The other downside (if done this way) is that the GC block's content cannot be inserted it the middle of another content block. You can get around this by splitting the content into "before" GC and "after" GC blocks. So you template code may looks something like this:

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"}
I just noticed that you were talking about a block of pages, so you may need to detection of parent alias in your conditional code as well.
Hope that help.
-S