Themester
Themester module allows automated file association based on the url path information. This module was initially built to help with cascading CSS style sheets properly based on the url taxonomy for any given page. Admin screen is mainly to accommodate css organization for themester, however Themester can be used to load any file type into the system via API functions.
INSTALLATION
----------------------------------------------------------------------
1. Copy the themester module directory to your modules directory (Usually sites/all/modules/)
2. Enable the module from admin/build/modules
3. Setup the themester configurations at admin/settings/themester
EXAMPLE USAGE
----------------------------------------------------------------------
For this example we will look at the url yoursite.com/admin/settings/themester
Once themester has been installed, it will automatically begin searching for files within
the current active theme directory.
If a directory is specified in the "Themester directory" field on the settings page, then themester
will search within that directory as the root for all style sheets.
NOTE: Themester does not overwrite the built in style sheet loading functionality, so if style.css
is located within your theme directory it will still be picked up. This is why we added the global
style sheet definition. This way global style sheets can be specified in order to maintain organizational
consistency.
Lets specify a directory of "css" in the themester directory field and a themester global style sheet
named "global". We do not include any extensions on this administration form.
NOTE: Drupal will automatically pull style.css from your theme's root if it exists.
With these settings themester will search for and load if found the following style sheets (from our
theme directory).
1. css/global.css
2. css/admin.css
3. css/settings.css
4. css/themester.css
Browser specific style sheets will also be found and written to the page via javascript after all regular (all browser) files.
This means that all browser specific style sheets will not work with CSS aggregation, since the style sheets are loaded and stored in the pages html output and not pulled in with drupal_add_css();
API USAGE
----------------------------------------------------------------------
Themester can be utilized to load other file type that may be needed with this same url taxonomy logic.
themester_load_file_list() is the main function that does all the work
<?php
/**
* Return an array of files to load.
* This function will return both the browser argument list
* as well as the global list of files that were found and should be loaded.
*
* @param $file_name
* String indicating a specific filename to search for. This allows for specific files to be loaded instead of the default
* functionality which is to look for the url string section.
* @param $search_directory
* String containing the directory to search in.
* @param $search_directories
* Boolean to overwrite the default directory searching settings.
* If neither TRUE or FALSE is specified then the function will use the default admin settings.
* This represents a switch to leverage url path names as directories as well as files "directory nesting".
* @param $file_extension
* String indicating the file extension to look for. This allows for multiple file types to leverage this function.
* @param $check_browser_args
* Boolean to determine in the function should check for a browser specific list of files.
* If neither TRUE is specified then the function will base its browser return on the global themester
* directory search setting.
*
* return
* Array containing the files that were found and should be loaded.
*/
themester_load_file_list($file_name = NULL, $search_directory = NULL, $search_directories = NULL, $file_extension = '.css', $check_browser_args = TRUE);
?>When checking for other file types, themester will automatically check if there is a theme function with that name.
for example:
<?php
themester_load_file_list(NULL, path_to_theme() . '/xml', FALSE, '.xml', FALSE);
// this will try and locate the filenames based on the url path with the extension .xml within the current theme location /xml.
// using this function will look for the following theme function to finalize the output. This is something that you will
// need to create.
theme_themester_add_xml($file_list) {
/*... your code
you will need to determine what happens to the $file_list elements ... */
}// end - function
?>Themester runs all final output through theme functions. For CSS this function is called theme_themester_add_css($file_list);
Themester will look for different theme functions based on the extension that it is searching for.
So in the above example themester will only load the xml files that it find if it is told to do so within a theme function defined
as theme_themester_add_xml($file_list);
$file_list is the array of files that were found.
NOTE: Themester only has themester_add_css defined, so any other file extensions should have the provided theme function in template.php
if we want the files to actually load. If the theme function is not found, the files will not load.
Sponsored by:
Tree House Agency and Lifetime Networks
Releases
| Development snapshots | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 5.x-1.x-dev | 2008-May-13 | 16 KB | Download · Release notes | Development snapshot | |
