Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-05-04 22:45:53

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#2 2010-05-04 22:58:14

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#3 2010-05-05 00:06:54

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#4 2010-05-05 21:20:20

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#5 2010-05-05 22:17:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,000
Website GitHub

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

#6 2010-05-05 23:31:43

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

Board footer

Powered by FluxBB