Page 1 of 1

Calling GCB depending on page?

Posted: Tue Mar 31, 2009 7:47 am
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

Re: Calling GCB depending on page?

Posted: Tue Mar 31, 2009 8:01 am
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

Re: Calling GCB depending on page?

Posted: Tue Mar 31, 2009 8:01 am
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

Re: Calling GCB depending on page?

Posted: Tue Mar 31, 2009 2:17 pm
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