Special Offer - Get $90 Discount and Host Your Dream Web Site @ Dreamhost for 1 Year Click Here. Promo Code SLJ345
Back To Top
WordPress Web Application Development
Develop Powerfull Web Applications Using Cutting Edge WordPress Development Techniques

Include Js and Css in Smarty Templates Using Literals

on 2011/04/24 6:05 AM stored in: Uncategorized and tagged:

Introduction to smarty literals

Smarty literals provide a way to include anything inside the tags without interpreting. Literals are useful when inserting javascript and css code inside your templates. Smarty uses delimiters to define its variables and code. The default delimiters of smarty is { and }. Since js and css contain these curly braces in the code it is not possible to insert js and css normally inside smarty templates. So we need to wrap the js and css code inside literals.

Including js in smarty tpl




Including css in smarty tpl


                

Customize default delimiters in smarty

You can change the default delimiter values inside the php code by changing the left_delimiter and right_delimiter variables of template object.


        $tpl = new Template();
        $tpl->left_delimiter = "";
        $tpl->assign('variable','sample_value');
        $tpl->display('test.smarty');


        
Sample smarty Template

Leave a Reply

Follow Us On Facebook