Jump to content

template (.tpl) unable to view?


Destramic

Recommended Posts

you need something to interpret the template file, either smarty or whatever the template was developed for. not every templating system uses the same... anything. without knowing what the template was created for, it's not possible to tell you exactly what system you'll need to use to display it.

If there's php code within the .tpl file, and you include() it in a .php script, it will be parsed by the php interpreter. If you call the .tpl file into the browser on its own, it won't. Is that what you're trying to figure out?

in my experience with smarty templates (.tpl), the PHP inside the .tpl file is modified to be 'smarty-friendly'. that is, there is no standard PHP, per se, but smarty-formatted PHP that looks like this:

 

{php}echo "hello world";{/php}

 

However, many times a .tpl file will have no PHP code at all, just smarty-type values, functions and loops which are a different syntax compared to PHP. for instance, here is a bit of code from a template:

 

{if $totalnumofrows gt 0}
	<h2>Showing <span id="showmatch"> {$LimitFrom+1} - {$LimitFrom+$pagenumofrows} of {$totalnumofrows}</span> matches</h2>
{elseif $totalnumofrows eq 1}
	<h2>Showing 1 match</h2>
{else}
	<h2>No matches found.</h2>
{/if}

 

The $ values in the template are defined outside of the template, then substituted into the template at run-time. in the case of smarty, setting the values before loading the template looks like this (PHP):

 

$smarty->assign('somevariable', 12345);

 

Then, inside the template, {$somevariable} will be replaced with 12345.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.