Page 1 of 1

Should I use smarty_cms_function_title?

Posted: Sat Jul 29, 2006 1:47 pm
by hansom
Let's say I want to create a tag/plugin and I need to access the current page's title. Should I call the smarty_cms_function_title() function in function.title.php or should I get it using something like &$gCms->variables['pageinfo']->content_title? What's the correct way of doing things?

I noticed that the using the smarty_cms_function_title() function results in an error while previewing content at Content » Pages » Edit Page...

Re: Should I use smarty_cms_function_title?

Posted: Sat Jul 29, 2006 4:08 pm
by Elijah Lofgren
hansom wrote: Let's say I want to create a tag/plugin and I need to access the current page's title. Should I call the smarty_cms_function_title() function in function.title.php or should I get it using something like &$gCms->variables['pageinfo']->content_title? What's the correct way of doing things?

I noticed that the using the smarty_cms_function_title() function results in an error while previewing content at Content » Pages » Edit Page...
I would access it like the title plugin/tag does it:

Code: Select all

global $gCms;
$pageinfo = &$gCms->variables['pageinfo'];
echo $pageinfo->content_title;
Accessing it that way should now work on page preview in latest CMSMS SVN (and when CMSMS 1.0 beta3 is released):
http://viewsvn.cmsmadesimple.org/viewsv ... 4&view=rev

Hope this helps,

Elijah

Re: Should I use smarty_cms_function_title?

Posted: Sun Jul 30, 2006 8:31 am
by hansom
Elijah Lofgren wrote: I would access it like the title plugin/tag does it:
Thanks. In general, are you saying that one should not make direct function calls like smarty_cms_function_title() or to other plugins when coding modules and plugins, but rather do it "like the title plugin/tag does it"?

Re: Should I use smarty_cms_function_title?

Posted: Sun Jul 30, 2006 7:26 pm
by Elijah Lofgren
hansom wrote:
Elijah Lofgren wrote: I would access it like the title plugin/tag does it:
Thanks. In general, are you saying that one should not make direct function calls like smarty_cms_function_title() or to other plugins when coding modules and plugins, but rather do it "like the title plugin/tag does it"?
I don't really know what is considered best. I think calguy100 or Ted would be better able to tell you.  ;)

I know that I've never directly called a "smarty_cms_function_()" before so I was more inclined to not do it.

If you'd like to try asking Ted or calguy1000 (in case they don't read this topic), feel free to come into the CMSMS IRC channel by clicking the "Chat" button at the top of the forums or go to the #cms channel on irc.freenode.net  :)