|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sedics Smarty n00b
Joined: 23 Nov 2006 Posts: 1
|
Posted: Thu Nov 23, 2006 5:29 am Post subject: Css and javascript in a header template |
|
|
Hey guys im new to smarty so done bite me, just came up with this idea i dont know if anyone has done it im sure you have but here goes.
In the header.tpl i have
<html>
<head>
<title>{$title|default:"no title"}</title>
{* Import the standard css file which will be used on this site *}
<link rel="stylesheet" type="text/css" href="styles/main.css" />
{* Import any extra CSS Style Sheets needed *}
{section name="styes" loop=$styleSheets}
{strip}
<link rel="stylesheet" type="text/css" href="{$styleSheets[stylesheet]}" />
{/strip}
{/section}
{* Add any Javascript files needed *}
{section name="mysec" loop=$scripts}
{strip}
<SCRIPT language="JavaScript" SRC="{$scripts[mysec]}"></SCRIPT>
{/strip}
{/section}
</head>
{* Render the start of the body *}
<body {$BodyTag}>
then in the index.php for example. I can do this
$smarty->assign('scripts', array('scripts/a.js'));
or however many items i want to include javascript scripts.
and
$smarty->assign('styles', array('styles/a.css'));
to add any extra stylesheets that some pages will need.
Then i can also do something like this
$smarty->assign('bodyExtra', "onLoad='test();'");
incase i need to run some javascript method when the page loads.
Hope this may help someone and i did not waste your time
Cheers
Stefan |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|