Portal Home > Knowledgebase > Articles Database > Easy way to parse certain vars for a template?


Easy way to parse certain vars for a template?




Posted by lexington, 12-09-2007, 12:24 AM
Hello, could anyone give me a simple example on how to make a php variable display on a template and what to place in that template for it to display properly? I created a language file with text and I thought a simple echo would do the trick until I realized that the template doesn't know what the variable is since it doesn't have an include commands in the file. I basically want it so it would be like: php file template file output displays Thanks.

Posted by bear, 12-09-2007, 12:27 AM
Here's one way of several:

Posted by lexington, 12-09-2007, 12:32 AM
Yeah sorry for the confusion I meant that I would like a php file to contain the variable and a separate template file to display the contents of that variable without having to use an include code. You know like most custom scripts out there like phpBB where the variables are in php and the template displays {PAGE_TITLE} and {PAGE_TITLE} is parsed on the page as the variable in the php file.

Posted by lexington, 12-09-2007, 01:02 AM
I am looking at a few scripts that I have installed that use templates and they all use a custom function for this.

Posted by tiamak, 12-10-2007, 10:35 AM
ah so u need some template engine? really basic code might look like: template file... php file... ofcourse this is very lame example - in "real life" you would need to add to your template engine at least while/for loops and if/else statements... but instead of wasting time for own template engine better use "smarty" or something similar



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Need advice (Views: 689)


Language: