I have following codes using smarty template engine
In php file:
$smarty->assign('SITE_URL', 'http://localhost/mis/');
In tpl file:
{literal}
<script type="text/javascript" src="{$SITE_URL}lightbox/js/prototype.js"></script>
<script type="text/javascript" src="{$SITE_URL}lightbox/js/scriptaculous.js?load=effects,builder"></script>;
<script type="text/javascript" src="{$SITE_URL}lightbox/js/lightbox.js"></script>
{/literal}
I want the codes to be rendered like below in html view
<script type="text/javascript" src="http://localhost/mis/lightbox/js/prototype.js"></script>
<script type="text/javascript" src="http://localhost/mis/lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="http://localhost/mis/lightbox/js/lightbox.js"></script>
Please help me with this.
{literal} is used to prevent variables, so you cannot do it like you described. Instead, you should close {/literal} tag before you want to use a variable.
{literal}<script type="text/javascript" src="{/literal}{$SITE_URL}{literal}lightbox/js/prototype.js"></script><br>{/literal}
Another solution is to replace your { and } for the javascript with {ldelim} and {rdelim}. No more need of {literal}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With