Jump to content

Archived

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

allex01

Call PHP Inside smarty template

Recommended Posts

How do i call php inside smart template tpl file such as

 

<?php $page = basename($_SERVER['SCRIPT_NAME']); ?>

<?php if ($page == 'index.php') { ?>class="active"<?php } ?>

Share this post


Link to post
Share on other sites

the whole point of smarty is to seperate PHP and HTML

 

first, you need to assign $page and $basename

 

so do something like:

 

$smarty -> assign ('page', basename($_SERVER['SCRIPT_NAME']) );

 

Don't put that in ur template, put it right before you $smarty -> display the template, okay?

 

Then in the template, put:

 

{if $page == 'index.php'} class="active" {/if}

 

Hope that helps!

Share this post


Link to post
Share on other sites

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