Global Content Block inside a User-Defined Tag

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.
Locked
BigFishPhilip

Global Content Block inside a User-Defined Tag

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Global Content Block inside a User-Defined Tag

Post by calguy1000 »

lib/classes/class.globalcontentoperations.php
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
BigFishPhilip

Re: Global Content Block inside a User-Defined Tag

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Global Content Block inside a User-Defined Tag

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
BigFishPhilip

Re: Global Content Block inside a User-Defined Tag

Post 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;
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Global Content Block inside a User-Defined Tag

Post 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;
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
BigFishPhilip

Re: Global Content Block inside a User-Defined Tag

Post by BigFishPhilip »

Beauty!  It was...

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

...and it worked a charm!

Thanks Calguy!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Global Content Block inside a User-Defined Tag

Post by calguy1000 »

Give a man a fish and he eats for a day..... yada yada yada :)
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “CMSMS Core”