page-specific global content

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
turpentyne
Forum Members
Forum Members
Posts: 34
Joined: Tue Oct 08, 2013 8:29 pm

page-specific global content

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

Re: page-specific global content

Post by Wishbone »

Can you be more specific in what exactly you are trying to do?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: page-specific global content

Post 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
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: page-specific global content

Post 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
Post Reply

Return to “The Lounge”