sudhakararaog Posted October 21, 2009 Share Posted October 21, 2009 in the index.tpl file which i access as http://localhost i am able to add the doctype and other tags <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>{$pagetitle}</title> </head> <body> vale of smarty variable is {$var1} </body> </html> all this works fine however when i add a link tag to call a css file as <link rel="stylesheet" href="style.css" type="text/css" /> the code for css is * { margin: 0; padding: 0; } body { font: normal 12px Arial, Helvetica, sans-serif; margin: 0; padding: 0; } this css style is not being applied to the index.tpl when i access the page as http://localhost how can i call the css file from index.tpl also if i am using a jquery plugin i need to use a script tag to call the javascript files, how do i call these javascript file from index.tpl file please advice. thanks Quote Link to comment https://forums.phpfreaks.com/topic/178421-using-a-css-file-with-smarty-template/ Share on other sites More sharing options...
dreamwest Posted October 21, 2009 Share Posted October 21, 2009 Direct css will need literal tags {literal} <style> { margin: 0; padding: 0; } body { font: normal 12px Arial, Helvetica, sans-serif; margin: 0; padding: 0; }</style> {/literal} Css can be called from an exteral file like youve shown but should contain the root command <link rel="stylesheet" href="/style.css" type="text/css" /> Make sure you refreash the page and also check to see that $smarty->compile_check is set to true $smarty->compile_check = true; , this will force template rebuid also if i am using a jquery plugin i need to use a script tag to call the javascript files, how do i call these javascript file from index.tpl file Just use the {literal} javascript here{/literal} tags Quote Link to comment https://forums.phpfreaks.com/topic/178421-using-a-css-file-with-smarty-template/#findComment-940952 Share on other sites More sharing options...
trq Posted October 21, 2009 Share Posted October 21, 2009 Another reason note to use a template engine. Its not natural, just another un-required complexity. Quote Link to comment https://forums.phpfreaks.com/topic/178421-using-a-css-file-with-smarty-template/#findComment-941053 Share on other sites More sharing options...
sudhakararaog Posted October 21, 2009 Author Share Posted October 21, 2009 thanks for replying when i use {literal} <style type="text/css"> body{ font: normal 12px Arial, Helvetica, sans-serif; } #wrapper{ width: 900px; margin: 0 auto; } </style> {/literal} this is working however if i use {literal} <link rel="stylesheet" href="/style1.css" type="text/css" /> {/literal} the css file is not being called, also i tried <link rel="stylesheet" href="c:/wamp/www/templates/template1/style1.css" type="text/css" /> the full path as with other smarty functions i had to give the entire path, even this is not working how can i call the css file without writting {literal} <style type="text/css"> body{ font: normal 12px Arial, Helvetica, sans-serif; } </style> {/literal} as the code will increase in the page also $smarty->compile_check = true; is already set in my index.php file please advice thanks Quote Link to comment https://forums.phpfreaks.com/topic/178421-using-a-css-file-with-smarty-template/#findComment-941515 Share on other sites More sharing options...
dreamwest Posted October 21, 2009 Share Posted October 21, 2009 You wont need {literal} tags when using external style sheets only if you add the style directly <link rel="stylesheet" href="/style1.css" type="text/css" /> Open your browser enter: http://localhost/SITE.COM/templates/template1/style1.css to see if the file actually exists, if it does youll include will work Quote Link to comment https://forums.phpfreaks.com/topic/178421-using-a-css-file-with-smarty-template/#findComment-941528 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.