$site = new Configuration();
$site->css = array(‘section’ => array(‘first.css’, ‘second.css’, ‘third.css’),
‘home’ => array(‘style.css’),
‘article’ => array(‘jquery.css’, ‘tools.css’, ‘grid.css’)
$site->js = array(‘section’ => array(‘first.js’, ‘second.js’, ‘third.js’),
‘home’ => array(‘super.js’),
‘article’ => array(‘jquery.js’, ‘tools.js’, ‘grid.js’)
Let’s also say you also have a variable which holds the current template name let’s call it $template now with this variable we can do something like this.
$template = ‘section‘;
$site->get_output(‘css’, $template); // This function returns html output it also has a third parameter which if false returns an array please return to the source code and read the parameter comments.
this part would be called before the <head> tag ends on your page, after you would view the source code you would see that all scripts for this template are loaded of course you still need to make create a template logic by that I mean a variable which holds the template name to automate the process and also the path to the css and js need to be changed but this is all easy done because I’ve included a small template logic to the class that lets you easy manipulate with it and also add your custom script templates (preffix and suffix) as you will see from the source code but also you will see that I have used PHP’s magic getter and setter functions which will let you add custom arrays for many different things but all this can only be achieved by further exploring the class.
<link rel=”stylesheet” type=”text/css” href=”first.css”>
<link rel=”stylesheet” type=”text/css” href=”second.css”>
<link rel=”stylesheet” type=”text/css” href=”third.css”>
I wont further explain the class because I seem to confuse everything I’m kind tired so take a look at the source code which includes a working example code.
I welcome every kind of feedback or suggestions, also If you have your own algorithm that handles the logic of implementing js and css scripts let me know I would like to learn more.
Here’s a little screenshot I’ve took
This image shows only dummy tests.
If you like to download the file it can be found here it also includes a working example of the code, but the code is self explaining so you wont have trouble using it.
Here’s also a Pastebin link
P.s. sorry for my bad English, but I’m pretty tired ^.^