allex01 Posted February 9, 2009 Share Posted February 9, 2009 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/144532-call-php-inside-smarty-template/ Share on other sites More sharing options...
allex01 Posted February 10, 2009 Author Share Posted February 10, 2009 anyone?? Quote Link to comment https://forums.phpfreaks.com/topic/144532-call-php-inside-smarty-template/#findComment-759058 Share on other sites More sharing options...
ds111 Posted February 10, 2009 Share Posted February 10, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/144532-call-php-inside-smarty-template/#findComment-759074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.