Saturday, April 28, 2012

Can you dynamically change CSS for a layout per user?

I see in the documentation how to change the layout in the controller.  
I also see how to include CSS files.

So, is it possible to include either inline CSS or create a temp File
with CSS info that is specific to a user?
For example, lets say I somehow allow user to change background and font
color.
Then could I

In controller
$newCss = '#content { background: black; color: white}';
$this->set('newCss ', $this->newCss );

In view/view.ctp
<?php echo $this->Html->css($newCss, null, array('inline' => true));  ?>

Or is this better?
In Controller
$file = new File('/webroot/css/users/" . $username, true, 0644);
$file->append($newCss);
$file->close;
$this->set('cssfile', '/webroot/css/users/" . $username);

in view/view.ctp
<?php echo $this->Html->css($cssfile, null, array('inline' => false));  ?>

It looks like I need to do this for Every Controller, Every method, and
Every View.
How can I make this DRY?

Thanks,
Bill





View this message in context: Can you dynamically change CSS for a layout per user?
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: