Jump to content

Using smarty variables in .php file?


Recommended Posts

Hi,

 

I wanted to know if we can use the tpl variables in a .php file? I want to get clientdetails and clientstats on a .php page. How can I access them?

 

The other question is more of a clarification. When we want to use a .tpl file in a php file then we use the display(tplfile) command. Am I right? If yes, then are all the smarty variables accessible to this tplfile? If I create a tpl file and use $clientsdetails.firstname in it will it work?

 

Thanks.

Link to comment
Share on other sites

  • 3 weeks later...

The Smarty templating system uses two unique files for each page to be rendered. One is the php file, which contains all the core programming logic, including the creation of the variables needed for the specific page. The second file is the tpl file used to display the page. The tpl file contains the layout of the page and it can access the variables defined in the corresponding php file.

 

The php processor has no knowledge of the Smarty syntax, only the Smarty processor does. If you put {$variablename} in a php file, it will result in the literal display, not the actual contents of the variable.

 

To use the display('templatefile') syntax, you must make certain that your php file that includes the display('templatefile') invocation has defined all the variables needed by the template file. And your php file must be defined as the example shown at:

 

http://wiki.whmcs.com/Creating_Pages

 

Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated