Calling varibles from a page

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
dwinters
Forum Members
Forum Members
Posts: 53
Joined: Mon Mar 17, 2008 12:46 pm

Calling varibles from a page

Post by dwinters »

I am sure this is in help somewhere but I have been searching for 4 hours and cant find

So really sorry if this is a simple one but.....

I have installed a UDT to help me see the variables I could use in a page / template / global block etc

// get a list of all of the smarty assigned variables
// user defined tag named "get_template_vars"
global $gCms;
$tpl_vars = $gCms->smarty->get_template_vars();
print_r( $tpl_vars );

And then try to use the vars I have found out about -- but cant seem to call them

Have tried {eval $var=content_title}
{eval $var=[content_title]}
{echo $var=[content_title]}
{content_title}
{smarty.get.content_title}

What is the right syntax!??
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Calling varibles from a page

Post by calguy1000 »

1.  There is an already existing {get_template_vars} plugin.  You didn't have to write a UDT
    go to Extensions >> Tags to see a list of the smarty tags that were provided by CMS Made Simple
    on most of the tags there is a help list on how to use them

2.  See http://smarty.php.net/manual/en
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.
dwinters
Forum Members
Forum Members
Posts: 53
Joined: Mon Mar 17, 2008 12:46 pm

Re: Calling varibles from a page

Post by dwinters »

Thanks - but still struggling with the syntax after reading the smarty site.
Do you have an example that might help me?

I found the UDT shows loads more variables for possible use than the built in one, is there a reason for this?


Also How do I close a post / topic off?
gap_tooth_clan

Re: Calling varibles from a page

Post by gap_tooth_clan »

I have had the same problem, I keep coming up with problems that would be easily solved with access to these variables.

My problem was I wanted to display either the page title or if it was set the page description as the page title for seo purposes, I tried to work out a solution in smarty for ages but it was just not working.

I found this post and thought it would be of some use but I did not know what to do with {get_template_vars} even after looking through the smarty manual I was still getting nowhere.

In the end I  used a UDT

global $gCms;
$pageinfo = &$gCms->variables['pageinfo'];

if ($pageinfo->content_titleattribute != '') {
  $result = $pageinfo->content_titleattribute;
} else {
  $result = $pageinfo->content_title;
}
echo $result;

I would be very interested in finding out how to do this with smarty.

Or is this the best way to handle this type of function keeping things seperated from the template?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Calling varibles from a page

Post by calguy1000 »

I know the page title is available in smarty, but I don't think the title attribute is, so your solution is probably pretty much what I would have done.
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.
Post Reply

Return to “Developers Discussion”