|
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 |
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 541
|
Posted: Fri Mar 28, 2008 2:53 pm Post subject: Theme templates/adding code to HEAD of html |
|
|
This may have been done before but:
I work with a CMS that uses Smarty. The theme template is separate from each individual page template, and the theme template controls what goes in the HEAD. Occasionally individual pages have to add something to the HEAD section of the HTML, could be more CSS, could be JavaScript.
So, before, the solution included appending the HTML to a CMS variable that represented the HEAD. For example:
$cms_head .= '<link rel="stylesheet" media="all" type="text/css" href="/templates/themes/abc/css/search_module.css" />';
But, since this is really part of the presentation, it should be done in Smarty. So the solution is to make a block function that adds code to the HEAD:
Code: |
function smarty_block_cms_html_head($params, $content, &$smarty)
{
global $cms_head;
if ($content !==NULL) {
$cms_head.=$content;
return '';
}
} |
And use it in the page template like this:
Code: | {cms_html_head}
<link rel="stylesheet" media="all" type="text/css" href="/templates/themes/abc/css/search_module.css" />';
{/cms_html_head} |
|
|
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
|