Stylesheet caching w/ smarty variables

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Stylesheet caching w/ smarty variables

Post by Jeff »

I just added a new plugin for stylesheet retrieval.

http://dev.cmsmadesimple.org/projects/smartstylesheet

It is a rework of the {stylesheet} which exports a static file for the page to use, it automatically updates when the stylesheet is updated.

I also added smarty processing with the delimiters of [[ and ]], so you can have [[assign var=color1 value='#c3c3ce']] at the top of the file and then use later with [[$color1]]

Just a reminder, when static stylesheets are created the background image location usually needs to be changed. An easy way I found to do it is have [[assign var=dir value='/mydir/']] (watch the '/') at the beginning of the file and then do a search/replace with 'url('/'url([[dir]]'
Tolekro
New Member
New Member
Posts: 2
Joined: Mon Feb 01, 2010 12:39 pm

Re: Stylesheet caching w/ smarty variables

Post by Tolekro »

Hi, I'm very insterested of using variables in stylesheets. Could you explain how to install and use this feature?

I have tried to do it  as following:
Uploaded file: function.smarty_stylesheet.php to /functions/ directory.
Replaced {stylesheet}-tag to {smarty_stylesheet} in page template.

After doing this I'm getting error: Fatal error: Call to undefined function cms_smarty() in /home/jannehav/public_html/plugins/function.smarty_stylesheet.php on line 71
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Stylesheet caching w/ smarty variables

Post by Jeff »

Sorry about that I accidentally uploaded my 2.0 version. I have now update it with the 1.6.x version.

http://dev.cmsmadesimple.org/projects/smartstylesheet
Tolekro
New Member
New Member
Posts: 2
Joined: Mon Feb 01, 2010 12:39 pm

Re: Stylesheet caching w/ smarty variables

Post by Tolekro »

Thank you for your great release.

I also noticed that function name should be changed from smarty_cms_function_stylesheet to smarty_cms_function_smarty_stylesheet to avoid redeclare error.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Stylesheet caching w/ smarty variables

Post by Jeff »

Thanks, fixed it.
Manuzzi
Forum Members
Forum Members
Posts: 17
Joined: Mon Aug 16, 2010 8:56 am

Re: Stylesheet caching w/ smarty variables

Post by Manuzzi »

ajprog wrote:
Just a reminder, when static stylesheets are created the background image location usually needs to be changed. An easy way I found to do it is have [[assign var=dir value='/mydir/']] (watch the '/') at the beginning of the file and then do a search/replace with 'url('/'url([[dir]]'
search/replace with 'url('/'url([[dir]]' should be: search/replace with 'url('/'url([[$dir]]'
Manuzzi
Forum Members
Forum Members
Posts: 17
Joined: Mon Aug 16, 2010 8:56 am

Re: Stylesheet caching w/ smarty variables

Post by Manuzzi »

The creation and edit date of the css file is getting the value 1-1-1970 in the tmp directory. Is their a way to let it generate the current date and time?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Stylesheet caching w/ smarty variables

Post by Dr.CSS »

This type of style sheet is now integrated into CMS Made Simple, it is {cms_stylesheet} and is included in all new installs/upgrades...
Locked

Return to “Tips and Tricks”