Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Using TXP Tags within Stylesheets
Hey Guys,
(I looked for answers to this before posting – But if this question has been raised before, please feel free to direct me to the relevant thread / FAQ)
I am wondering whether there is a way to use the TXP tags within the Stylesheet section?
Specifically, I am wanting to use the ako_ifBrowser tags so that browser specific styling can be applied through the stylesheet itself (avoiding the clunky CSS Hacks currently used for most sites).
I have tried using the <code><txp:php></code> tags, but it seems that the css.php script does not run the retrieved data through the substitution engine like index.php does.
I would rather not have to create a different stylesheet for each group of browsers (and then use the ako_ifBrowser tags to specify which one to use).
Any suggestions, ideas, shared experiences, etc.?
Thanks
Luke
Offline
Re: Using TXP Tags within Stylesheets
To my experience you will have to generate external style sheets to do what you are looking for and use the ifBrowser tag to call your stylesheets for targeting specific user agents. Someone may have something else to add, but in my experience no php is going to be parsed through css.php. You may be able to jury rigg something with a php style switcher in conjunction with ako_ifBrowser. And I know someone is going to step in now and say that browser “sniffing” in this manner is frowned upon. :) But in the real world, on a commercial site for example, where it has to look the same on all platforms, it is sometimes unavoidable.
Offline
Re: Using TXP Tags within Stylesheets
In a perfect world, CSS would be result in identical results in all browsers.
But, I guess we don’t live in a perfect world…
I was mainly looking at whether there was a way to have the database content which css.php must be retrieving, through the same taghandling function which the index.php page uses to process the database content for each page.
I mean, if I had all the CSS information in the page itself, I could easily use the ako_ifBrowser tags to select which information to include, and not include in the final, rendered page.
Offline
#4 2006-03-17 20:27:29
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Using TXP Tags within Stylesheets
…a way to use the TXP tags within the Stylesheet section?
The answer is: built-in, no. Modifying css.php, yes. (Little disclaimer: that wouldn’t be supported, though.)
BUT, there’s no reason you can’t use ako_ifBrowser to feed separate stylesheets, so I don’t really see a benefit.
Offline
Re: Using TXP Tags within Stylesheets
Thank you for your response Mary!
(You seem to be one of the gurus here)
The benefit derived from using tags within the CSS is that they then provide an alternative to maintaining multiple browser-specific stylesheets (calling them from the page, dependant on the browser) or using CSS Hacks (which are messy). So, by simply having one CSS file, with the tweaky code surrounded by the applicable TXP tag, it is easier to keep the coding as clean and compact as possible.
Also, in my application of TextPattern I have defined a page layout using one page and one CSS entry, and then I allow the individual sections to be customised by way of colors and graphics through smaller CSS files. I was even toying with the idea of using the TXP:PHP tags in the CSS to allow for further automation of the customisations (doing things like calculating the shades for a site’s primary colors and plugging them into the rest of the CSS).
I just think it is a nice touch, considering the CSS seems to be the only main section of the presentation segment which cannot handle TXP markup (ie both Pages and Forms can).
As I said – thanks for your response.
Offline
Re: Using TXP Tags within Stylesheets
You might want to try something like create a specific section (and a page for it), and include it externaly.
Like create a css section, and use a :
@import url(http://www.yoursite.tld/css/);
I never tried it, but it should work. After all, a TXP page is nothing but text, so is CSS.
Offline
#7 2006-03-17 22:11:30
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Using TXP Tags within Stylesheets
Txp pages get sent with a header content type of text/html, while CSS is text/css.
Offline
Re: Using TXP Tags within Stylesheets
Indeed.
So one would need a hard include before processing and sending to the UA.
Offline
#9 2006-03-17 22:56:35
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Using TXP Tags within Stylesheets
(That/this also wouldn’t be supported… :D)
So one would need a hard include before processing and sending to the UA.
By hard include, do you mean sending another header overriding the text/html, and then close the connection (possible), or are you talking about something else?
Offline
Re: Using TXP Tags within Stylesheets
I’m talking something like parsing the CSS with PHP, or Apache’s SSI, and remotely include the /css/ page before the css file is formed and sent. To bypass the content type.
But then, we’re back to hacking css.php or something similar.
The only way that I can see without hack is to use Apache’s SSI, and use an external css file. Ask Apache to process it with SSI, and include whatever you want in it.
Offline
#11 2006-03-18 02:56:41
- marios
- Archived Plugin Author
- Registered: 2005-03-12
- Posts: 1,253
Re: Using TXP Tags within Stylesheets
Depending on wether you prefer your markup clean or not, another way to circumvent this limitation could be to use this inline in your page templates and target your problem divisions specifically.
Something like this:
<code><p style=“color:[same as in stylesheet, in case the plugin tag doesn’t generate any output];<txp:ako_if_browser>your style rule here</txp:ako_if_browser>”>test paragraph</p></code>
Better like this:
<code><p <txp:ako_if_browser>style=“any”</txp:ako_if_browser>”>test paragraph</p></code>
EDIT.:Just out of curiosity, tried this andSeems to work but not with opera for me.(tested Firefox and camino on MAC OS)
That will validate as XHTML strict but mostly inline styles should be avoided.
Worth checking allso if the plugin works with 4.03.
regards, marios
Last edited by marios (2006-03-18 03:30:48)
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
Re: Using TXP Tags within Stylesheets
When or if this could be accomplished in future releases, the potential for some really incredible things could be done with css alone. I feel tingly just think about it. Not that there isn’t a few tons of “other fish to fry” first, but hey, that gets me excited.
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline