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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.