Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Grab a style from the URL
This is beyond my scope so calling all the scripters out there.
If I have a URL call similar to this:-
http://demo.com/optimize/index.php?style=dark-blue
is there a way of grabbing the end bit ie. dark-blue
or indeed anything that follows the =
sign and popping it into a style tag like so:-
<link rel="stylesheet" type="text/css" media="screen" href="<txp:site_url />site-design/styles/dark-blue.css" />
I could do with some help with this one. ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Grab a style from the URL
Use adi_gps to grab the value of style
and assign it to a variable.
Code is topiary
Offline
Re: Grab a style from the URL
To mix it more, PHP:
<txp:php>
echo gps('style');
</txp:php>
If you already using rah_function:
<txp:rah_function call="gps" name="style" />
Offline
Re: Grab a style from the URL
Thanks Jeff and Jukka. Both methods work but only to a limited degree and both to the same degree. When I am viewing a demo theme the initial colour switch works, but once I start to navigate through the sections of the demo theme the colour switch is lost because the ?style=dark-blue
is removed. The URLs revert to what you would normally get as you navigate a site. Somehow I need to retain the switch until such time as another colour-variation is picked. Does that make sense? I can point you at the demo site if it helps.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Grab a style from the URL
Perhaps you can achieve the same with chs_cookie. Here’s a chs_cookie version with more complete help. As Stef noted recently, the plugin could do with some general love but it works.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Grab a style from the URL
Thanks Jakob. I’ve installed it into one of the themes but it is getting late here so I shall have a good look at it tomorrow and report back.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Pages: 1