I’m looking to convert parts of an existing site that’s currently built with PHP and Smarty to a CMS. So, I’m checking out EE to see if it fits my needs.
For those that know Smarty, in the PHP files we currently do something like this:
$styles[] = 'css1.css';
$styles[] = 'css2.css';
$doc->assign('styles', $styles);
$scripts[] = 'script1.js';
$scripts[] = 'script2.js';
$doc->assign('scripts', $scripts);
$doc->display('some_page.tpl');Within some_page.tpl, I’ll call header.tpl, and in <head> section it’ll step through those 2 css files and link to them, and then the 2 js files and link to them.
So far the only solution I’ve come up with in EE is this:
in header template:
<html>
<head>
<?php global $add_styles; ?>
{embed="styles/base_css" add="<?php echo $add_styles; ?>"}
{embed="scripts/base_js"}
</head>
<body>in page template:
<?php
global $add_styles;
$add_styles = "external/blog|external/index|external/alt_terms";
?>
{embed="site/header"}in base_css:
{if "{embed:add}" != ""}
<?php
$splitcontents = explode('|', '{embed:add}');
foreach($splitcontents as $file)
{
echo '<link href="/css/'.$file.'.css?v={site_version}" rel="stylesheet" type="text/css" />'."\n";
}
?>
{/if}This is dirty and makes me feel dirty!
Is there a better way to accomplish this without a bunch of php, ideally something built into EE that I can set in the page template and step through in header or base_css? We’ll be keeping our css and js files in svn repo as we’re not moving everything over to the CMS and want them easily accessible by the rest of the site.
Thanks for any help!
-Tommy