[solved] Can i use a global content block specific for each page?

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
jvdoorn
New Member
New Member
Posts: 8
Joined: Thu Oct 02, 2008 3:27 pm

[solved] Can i use a global content block specific for each page?

Post by jvdoorn »

Using cms ms 1.5.3

I have a lot of pages that all have the same template. But same of them have a different header-images (slideshow in a list ) that are outside of the {content}.

I was thinking to create different global content blocks and include them, so i can use the same template for each page.
And then include the global content block for each page with Page > Option > Extra Page Attribute 1

When i use {global_content name='contentblockname'} as 'Extra Page Attribute 1' then it just prints outs this as text.

Of course i could just include the html-content in 'Extra Page Attribute 1' but it's not easy to edit the html in this text field, and i use the same header-images on some pages so using global content blocks would be a lot easer to maintain.

Is there a way to do this?
Last edited by jvdoorn on Thu May 14, 2009 10:33 am, edited 1 time in total.
new2thiscms
Forum Members
Forum Members
Posts: 47
Joined: Thu Nov 09, 2006 7:33 pm

Re: Can i use a global content block specific for each page?

Post by new2thiscms »

Hi,

I don't know about using the Extra attribute but you could add a content block oneline and assign it a value and call it. Also you can create a standard so if it isn't assigned then it automatically uses the standard global_content.

Here is an example

{content block="headerfile" oneline="true" assign="headerfile"}
{if $headerfile != ''}
{global_content name="$headerfile"}
{else}
{global_content name="standard"}
{/if}

Thanks,

Chris
jvdoorn
New Member
New Member
Posts: 8
Joined: Thu Oct 02, 2008 3:27 pm

Re: Can i use a global content block specific for each page?

Post by jvdoorn »

Hi,

Thanks for you’re reply, but i can't seem to get this code to work.

I have made a couple of global_content blocks, let’s say headerblock1 and headerblock2

In my template i have:
{global_content name="$headerfile"}


And in the page options under "Smarty data or logic that is specific to this page:" i use this:
{content block="headerfile" oneline="true" assign="headerblock1"}

but this gives a "string(55) "Smarty error: unable to read resource: "globalcontent:"" error.

Cheers.
new2thiscms
Forum Members
Forum Members
Posts: 47
Joined: Thu Nov 09, 2006 7:33 pm

Re: Can i use a global content block specific for each page?

Post by new2thiscms »

sorry for the confusion...

In your template it should look like this then

Code: Select all

{content block="headerblock" oneline="true" assign="headerblock"}
{if $headerblock != ''}
{global_content name="$headerblock"}
{else}
{global_content name="standard"} 
{/if}
*Note Standard is the global content block that you would want to show if the content block is not filled out

Then you go to your page and you will see a content block oneline under your main content area. In that put the name of your GBC that has the header that you want on that page. Then it will replace the $headerblock in here {global_content name="$headerblock"} with the name of the GBC that you want the header to be.

This will allow you to have any different header slideshow on any page. It will just keep replacing $headerblock with sportsheaders or natureheader whatever you decide and as long as you have those as your GBC name your shouldn't get an error. Not sure if there is a better way but it works for me.

Chris
Last edited by new2thiscms on Wed May 13, 2009 2:12 pm, edited 1 time in total.
jvdoorn
New Member
New Member
Posts: 8
Joined: Thu Oct 02, 2008 3:27 pm

Re: Can i use a global content block specific for each page?

Post by jvdoorn »

A ha! I see. Thanks a lot for your help.

Got it working now!
new2thiscms
Forum Members
Forum Members
Posts: 47
Joined: Thu Nov 09, 2006 7:33 pm

Re: [solved] Can i use a global content block specific for each page?

Post by new2thiscms »

Glad to help!
Post Reply

Return to “CMSMS Core”