Page 1 of 1

Content to UDT elegantly, page or GCB?

Posted: Wed Feb 23, 2011 2:37 pm
by asdf
I need to merge HTML-content that is editable in the CMSMS admin system into output that is produced by UDT. Each content is quite short, 2-3 paragraphs, each 5-10 rows. The content will not be shown elsewhere and which one is chosen depends on what the UDT does.

I could get page in following http://forum.cmsmadesimple.org/viewtopi ... 07#p237407 as well as global content block following http://forum.cmsmadesimple.org/viewtopi ... 52#p228652 .

Maybe it's just me :) but somehow I don't like either. A page feels too much, it's not a page but just part of it. On the other hand the trick to do GCB is not pretty to me, calling some 'random' module to get content does not sound too 'pure'.

UDT should be able to test if content X exists, so if it not, it could do something instead saying: "Smarty error: unable to read resource: globalcontent..." as can happen with GCB method.

Please advise me with this problem? Or is there third, an elegant and clean option? I wouldn't mind to use an extra module, providing it was widely used and updates would be available if needed after core changes.

Re: Content to UDT elegantly, page or GCB?

Posted: Thu Feb 24, 2011 12:49 am
by jmcgin51
asdf wrote: On the other hand the trick to do GCB is not pretty to me, calling some 'random' module to get content does not sound too 'pure'.
? I don't follow...
asdf wrote: UDT should be able to test if content X exists, so if it not, it could do something instead saying: "Smarty error: unable to read resource: globalcontent..." as can happen with GCB method.
I have a GCB that is usually empty, and I just test for its contents when the page loads. If empty, the GCB is ignored. If there is some content, then it is displayed. No error is shown if empty.

I'm still not 100% sure I understand what you're needing.

Re: Content to UDT elegantly, page or GCB?

Posted: Thu Feb 24, 2011 4:18 pm
by asdf
I meant with 'pure' this part:

Code: Select all

$gCms->modules[$modules[0]]['object'];
On my system $modules[0] happens to be CMSMailer. It's just that I find it not that nice to go this way, it works same way with $modules[1] too. Why to call 'random' module when all you need is to access GCB. Sorry that I cannot express myself, hope you get the idea. I do admit I do not know CMSMS internals so this may be very well the only way to access data. If that's the only way I can live with it.

Thanks, maybe I just missed how GCB can be tested. Will have a look, must be doable.

Re: Content to UDT elegantly, page or GCB?

Posted: Thu Feb 24, 2011 4:38 pm
by Jos
In stead of this

Code: Select all

$gCms->modules[$modules[0]]['object'];
You can use this

Code: Select all

$gCms->modules['CMSMailer']['object'];

Re: Content to UDT elegantly, page or GCB?

Posted: Fri Feb 25, 2011 12:31 pm
by asdf
Thanks for the tip, but that is exactly what I consider non-elegant. Why to use mailer or whatever module to access global data instead of using more general way, that was my point. But it seems there's no such way, so I just must live with the fact.