I am quite new to CMSMadeSimple so am having to follow the documentation pretty closely while I learn the system. I have been trying to come up with a methodology to avoid having to have a separate template *and* stylesheet for each to page to be able to support different colours for different sections of the site. I tried adding some logic at the top of the stylesheet via custom tags to get the current section and set the colours accordingly but caching breaks this (since they are cached on the first run through every section gets the same variable values).
So I decided to try to use the {cms_stylesheet name="foobar"} approach with the name value being set by the calling template dynamically. However, after multiple variations and the stylesheet not showing up in the page output, I ended up searching the codebase to see how cms_stylesheet was being generated. After adding some debug statements to get the query and arguments I noticed the following:
When a "name" parameter is passed to {cms_stylesheet}, the method "smarty_cms_function_cms_stylesheet()" in the file ./plugins/function.cms_stylesheet.php will create the following query to lookup the stylesheet:
Code: Select all
SELECT DISTINCT A.css_id,A.css_name,A.css_text,A.modified_date,
A.media_type,B.assoc_order
FROM cms_css A, cms_css_assoc B
WHERE A.css_id = B.assoc_css_id AND A.css_name = "my_stylesheet_name" ORDER BY B.assoc_order
I am not sure whether to call this a bug or a documentation problem (I am leaning towards it being a bug) but in the meantime the work around is to create a dummy template and then associate the special use stylesheet with it.
I expect the fix here is to just change the logic to skip the join if the name parameter is passed (and exists) but I have not delved deep enough to know if that would lead to any issues elsewhere in the codebase.
Cheers