Adding Javascript To Smarty Templates

Wed, Jan 2, 2008

Programming & Code


I was figuring out how to include Javascript in Smarty templates this afternoon, because you can’t include them directly. After digging around a bit, I realised that all you had to do was to include the Javascript code within {literal}{/literal} tags, like this:

{literal}
<script type="text/javascript">
var currentTime = new Date()
var year = currentTime.getFullYear()
document.write(year)
</script>
{/literal}

And once that’s done, you can use Javascript in your Smarty template. Problem solved! :)

Similar Posts:

Tags: , ,
, ,

This post was written by:

- Alvin is a Singaporean who's interested in marketing, techy stuff and likes to just figure out how the two can work with each other. On top of his blog, you can also follow him on Twitter.

Get Alvin's Report On How To Blog Successfully - Free!

Leave a Reply

*