Pligg Templates use
Template Lite, a variation of the
Smarty template engine. Because of this you are unable to simply write PHP code in the .tpl files and expect it to render as PHP would. But using a {php} tag within your template files will allow you to use PHP in your templates. See below for examples of how to use PHP in a Pligg template file.
Code:
{php}
// PHP examples for printing the current date and time in various formats
//07/23/09
print date("m/d/y") . "";
//Thu, July 23rd
print date("D, F jS") . "";
//Thursday, July 23rd 2009
print date("l, F jS Y") . "";
//10:10 AM
print date("g:i A") . "";
//Thu, 23 Jul 2009 10:10:53 -0400
print date("r") . "";
//10:10:53 AM Thu, July 23rd 2009
print date("g:i:s A D, F jS Y") . "";
{/php} Using an example from above you could easily insert the current time to the header.tpl file. Below is an example that places the PHP after some Smarty variables that display the logged in user's name if the user is logged in.
Code:
{if $user_authenticated eq true}Welcome {$user_username}.{/if} The current time is {php}print date("g:i A");{/php}. Expanding on this idea we can even use {if} conditions that will wrap around {php} tags. For example if we want to redirect users to pligg.com when they try to access the submit page we could use a combination of a pagename variable and PHP's header redirect ability to forward them to another page. The sample code below will do just that and would be added somewhere at the top of either the pligg.tpl file so that it would redirect before the page loads any content.
Code:
{if $pagename eq "submit"}{php} header( 'Location: http://www.pligg.com/' ) ;{/php}{/if}