CSS Choice
Permalink 1 user found helpful
Is there a way for the user to be able to choose a css like below?
For example, letting them choose between blue or pink. It's not a theme switcher and this option would only be accessible by the admin.
<link rel="stylesheet" type="text/css" title="blue"
href="http://example.com/css/blue.css">
<link rel="alternate stylesheet" type="text/css" title="pink"
href="http://example.com/css/pink.css">
For example, letting them choose between blue or pink. It's not a theme switcher and this option would only be accessible by the admin.
<link rel="stylesheet" type="text/css" title="blue"
href="http://example.com/css/blue.css">
<link rel="alternate stylesheet" type="text/css" title="pink"
href="http://example.com/css/pink.css">
A quick hacky way to let only the admin/super user have access to change this:
Make a separate page and deny everyone access to read/write/edit etc. Record its collection ID number and modify the code I posted earlier:
$c->getAttribute...
becomes:
Page::getByID(##)->getAttribute...
where ## is the collection ID of said page. Now, only the admin can edit the page (thus change its page attributes).
The obvious downside is that anyone else with access to edit pages will see that page attribute available, however, unless they modify it on that specific page you created it won't have any effect.
Like I said, hacky, but best I could come up with in 5 minutes :)
Make a separate page and deny everyone access to read/write/edit etc. Record its collection ID number and modify the code I posted earlier:
$c->getAttribute...
becomes:
Page::getByID(##)->getAttribute...
where ## is the collection ID of said page. Now, only the admin can edit the page (thus change its page attributes).
The obvious downside is that anyone else with access to edit pages will see that page attribute available, however, unless they modify it on that specific page you created it won't have any effect.
Like I said, hacky, but best I could come up with in 5 minutes :)
I think this is the way to go. Just to clarify, you create that attribute by going to Dashboard -> Pages and Themes -> Attributes (little tab at the top), then pick "Select" from the dropdown list and click "Add". Fill out the info and add the various options there and then save, then continue with bbeebe's instructions above.
Ugh, forum threading not making this clear -- what I meant is that bbeebe's FIRST response is the way to go, and my instructions pertained to that. I don't think his second response makes sense for your particular situation (as he says, it's super hacky, and I think the first response will solve your problem just fine).
You'll also want to have a default stylesheet ready in case you didn't select any for a particular page.
It's just a matter of adding a simple logic check to my first post:
It's just a matter of adding a simple logic check to my first post:
<?php $strCssFile = $c->getAttribute('select_option_handle_name_here'); ?>
<link rel="stylesheet" media="screen, projection" type="text/css" href="<?php echo $this->getStyleSheet($strCssFile)?>" />