Calling GCB depending on 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
sarah_h
Forum Members
Forum Members
Posts: 189
Joined: Tue Apr 25, 2006 8:30 am

Calling GCB depending on page?

Post by sarah_h »

Hi All,

I'm trying to find a way of calling a GCB depending on what page the viewer is current on. So this is what I've tried:

{global_content name='home'}

{global_content name='{title}'}

So the intention is that the correct GCB will be called for a page i.e. home GCB for home page, contact GCB for contact etc.

Of course my attempt doesn't work: string(61) "Smarty error: unable to read resource: "globalcontent:{title"" }

So I'm wondering whether creating a UDT to do something would be more appropriate? I'm not hot on UDT's so I could sure do with some pointers...

Sarah
alby

Re: Calling GCB depending on page?

Post by alby »

sarah_h wrote: I'm trying to find a way of calling a GCB depending on what page the viewer is current on. So this is what I've tried:

{global_content name='home'}

{global_content name='{title}'}

So the intention is that the correct GCB will be called for a page i.e. home GCB for home page, contact GCB for contact etc.
???
GCB is usefull because you can re-use on many pages but USELESS for ALL pages
If you want you can use {global_content name="$page_alias"}
but my advice is: use ANOTHER content block
{content block="second_content"}

Alby
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Calling GCB depending on page?

Post by RonnyK »

What is the use for a GCB, when it is different based on the page it is on, that seems more like calling a second content-block instead.

GCBs are for re-usable content. $page_alias could be used btw.....

Ronny
sarah_h
Forum Members
Forum Members
Posts: 189
Joined: Tue Apr 25, 2006 8:30 am

Re: Calling GCB depending on page?

Post by sarah_h »

Thnaks for your comments on this. I'm confused because I thought this would be the best way to do what I want  ???

I have 1 template from which I want to call different content depending on page name. But I can see what you both mean. You're right, of course, and I'd be able to see the content for a particular page.

Ok, my method is plainly wrong!!! I'll do it using content blocks.

Thank both of you for putting me straight.

Sarah
Post Reply

Return to “CMSMS Core”