Should I use smarty_cms_function_title?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
hansom

Should I use smarty_cms_function_title?

Post 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...
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: Should I use smarty_cms_function_title?

Post 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
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
hansom

Re: Should I use smarty_cms_function_title?

Post 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"?
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: Should I use smarty_cms_function_title?

Post 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  :)
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
Post Reply

Return to “Developers Discussion”