Page 1 of 1

Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:18 pm
by BigFishPhilip
Hello all,

I'm trying to use Global Content Blocks to only contain content, to make it easier on my client.  I'm then using the User-Defined Tags to store both PHP and HTML, by closing php and re-opening... "?><?". 

It's mostly working well, but I'd like to be able include a Global Content Block INSIDE my UDT.  This way, my client could update the text, without having all the PHP/HTML in the way, and I can reuse the UDT around the site.  When I put {global_content name='test'} in the UDT, it outputs that exactly, instead of the content.

Can anyone point me in the right direction?

Thanks,
Philip Light

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:21 pm
by calguy1000
lib/classes/class.globalcontentoperations.php

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:40 pm
by BigFishPhilip
Thanks Calguy,

Not sure I understand though.  Am I on the right path trying to call this from the UDT...

echo $this-> LoadHtmlBlobByName('estimate_request_content');

Thanks as always,
Philip

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:44 pm
by calguy1000
Well it's the right method.... but in a UDT there is no class.... so you'll have to load the globalcontentoperations object from the $gCms object..... take a look in class.global.inc.php.

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:56 pm
by BigFishPhilip
This is a bit bit over my php-head...lol.  Something like?...

global $gCms;
$gc = GlobalContentOperations::LoadHtmlBlobByName('estimate_form_content');
echo $gc->content;

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 9:59 pm
by calguy1000
I think that's close..... but you need to load the contenblock operations method.... and without looking up the syntax (you'll see the exact function names in the class.globa.inc.php and class.globalcontentoperations.inc.php

it'd be something like:

Code: Select all

global $gCms
$gcbops =& $gCms->GetContentBlockOperations();
$obj =& $gcbops->LoadHtmlBlobByName($name);
return $obj->content;

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 10:24 pm
by BigFishPhilip
Beauty!  It was...

global $gCms;
$gcbops=&$gCms->GetGlobalContentOperations();
$obj=&$gcbops->LoadHtmlBlobByName("test");
return $obj->content;

...and it worked a charm!

Thanks Calguy!

Re: Global Content Block inside a User-Defined Tag

Posted: Sat Dec 08, 2007 10:34 pm
by calguy1000
Give a man a fish and he eats for a day..... yada yada yada :)