Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2006-03-18 18:08:45

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

Further…

I added a second “=” sign into the if statement.
That one didn’t generate a PHP Error on the main screen, as the one previous did.
Instead the CSS.php?n=XXX code contained an error:
“<b>Fatal error</b>: ob_start(): Cannot use output buffering in output buffering display handlers in <b>/home/lucanos/public_html/portal/textpattern/publish/taghandlers.php</b> on line <b>1723</b>”

Offline

#17 2006-03-18 18:09:48

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Using TXP Tags within Stylesheets

Well, ahem, it should be ==, not =. Little typo there.

Offline

#18 2006-03-18 18:13:01

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Using TXP Tags within Stylesheets

The limitation of that approach is, that you cannot use tags which use output-buffering themselves, there is very, very few tags that do. txp:php is one of them, though. (And you can work around that by replacing direct php-code with proper plugins).

Offline

#19 2006-03-18 18:23:19

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

Funnily enough, the tag I was trying to use was txp:php, just for the fact that it was an easy test – echo "/* It Works! */";

I’ll have to retest with standard TXP tags.
It would be good though, if, eventually, it would be possible to include the txp:php tags in the CSS code – it would allow funky things like having the shades of a color automatically calculated, etc.

Offline

#20 2006-04-01 18:48:44

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: Using TXP Tags within Stylesheets

Lucanos,
Where are you at with this? Any movement toward including the tags inside the internal css?


Offline

#21 2006-04-02 11:44:40

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

ma_smith,

At present I am looking through the coding, and reverse-engineering the way that the standard content is processed. As far as I can tell (at the moment), and correct me if I’m wrong, the function testpattern() actually performs the SQL query and then processes the txp tags therein before rendering the page’s source for display…

If that is the case, then what I am thinking of doing is creating a duplicate of that function (with a different name, of course) and then including that within the css.php page.

I’ll be working towards that this week, as I now have the luxury of 2 weeks project work on a TXP-based intranet site at work.

I’ll be sure to update you if and when I make any progress.
If you see my headed off-track though, let me know as I am still very new to TXP.

Thanks

Offline

#22 2006-04-02 14:05:14

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: Using TXP Tags within Stylesheets

Lucanos,
Unfortunately, I’m not well versed in php. That might be the kind of question you could ask on the dev mailing list, although they often request many “how do I’s” here in this forum. I am eager to know what you come up with, feel free to ask for beta testing and I’ll give you a hand there.

Cheers,

Matthew


Offline

#23 2006-04-05 02:33:13

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

I Got One!

I have changed the css.php file, using the functions which handle the normal page content, so that TXP tags (and PHP scripts, if you have chosen to allow them) can now be used within your stylesheets for further flexibility.

In conjunction with the Plugin: ako_ifBrowser this should also allow for browser-dependant CSS hacks to be easily applied to TextPattern sites, rather than relying on less-than-dependable tricks…

How to do it

Simply perform the following replacements inside the “@/textpattern/css.php@” file.
( = Remove this line. + = Add this line. )
<code>if (@ini_get(‘register_globals’)) foreach ( $_REQUEST as $name => $value ) unset($$name);

- header(‘Content-type: text/css’);

ob_start(NULL, 2048);
include ‘./config.php’;
ob_end_clean();

$nolog = 1;
define(“txpinterface”, “css”);
include $txpcfg[‘txpath’].’/publish.php’;
- $s = gps(‘s’);
- $n = gps(‘n’);
- output_css($s,$n);

+ if (gps(‘n’)) {
+ $cssname = $n;
+ } elseif (gps(‘s’)) {
+ $cssname = safe_field(‘css’,‘txp_section’,“name=’”.doSlash($s).”’”);
+ }
+ $css = safe_field(‘css’,‘txp_css’,“name=’”.doSlash($cssname).”’”);
+ if ($css) {
+ $css = base64_decode($css);
+ $css = parse($css);
+ $css = parse($css); // the function so nice, he ran it twice
+ $css = ($prefs[‘allow_page_php_scripting’]) ? evalString($css) : $css;
+ } else {
+ $css = “/* No CSS Content retrieved */”;
+ }

+ header(‘Content-type: text/css’);

+ echo $css</code>

I am pretty sure that some of the editing I did stripped the debugging information which I have sometimes seen displayed at the bottom of the source code for TXP pages, but, at a basic level at least, this works.

If someone wants to tidy it up, and replace any essential items I have (naively) removed, please feel free.

If editing the PHP file is a bit of a stretch for you, then you can download a copy, with the above changes already made, at www.lucanos.com/css_php.zip

Offline

#24 2006-04-05 06:02:23

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

OK…. I was a little premature…
The above works like a charm when you use the ...css.php?s=XXX method to call it. Unfortunately, the ...css.php?n=XXX method… She no work so good…

Figuring it out now…

Offline

#25 2006-04-05 06:12:11

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

OK.
Fixed.

Amendment to above is:
<code>define(“txpinterface”, “css”);
include $txpcfg[‘txpath’].’/publish.php’;
$s = gps(‘s’);
$n = gps(‘n’);
- output_css($s,$n);

+ if ($n) {
+ $cssname = $n;
+ } elseif ($s) {
+ $cssname = safe_field(‘css’,‘txp_section’,“name=’”.doSlash($s).”’”);
+ }</code>

So you keep the declarations setting $s & $n to gps(‘s’) & gps(‘n’) and you change the if/then/else condition after that so it looks at the $s & $n variables instead of the gps(.) results.

I will update the zipped version to reflect this fix. (Done)

Last edited by Lucanos (2006-04-06 00:46:27)

Offline

#26 2006-06-28 00:40:10

rloaderro
Archived Plugin Author
From: Costa Rica
Registered: 2006-01-05
Posts: 190
Website

Re: Using TXP Tags within Stylesheets

Lucanos wrote:

The above works like a charm when you use the ...css.php?s=XXX method to call it. Unfortunately, the ...css.php?n=XXX method… She no work so good…

hi Lucanos! I am using your hack and so far no problems – BUT – the css.php?n=xxx method still doesn’t seem to work!? I am using a simple <txp:section title="1" /> test – the s=xxx method works fine, but n=xxx returns no result. I haven’t figured out yet why this is. Any ideas?


Travel Atlas * Org | Start Somewhere

Offline

#27 2006-06-28 02:10:58

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Using TXP Tags within Stylesheets

Hmmm…
First I have heard of it.
I have a site here which uses this hack and operates fine with both n=xxx and s=xxx calls.
Sling me an email at lucanos@gmail.com and we’ll see what we can see.

Offline

#28 2006-06-28 03:06:16

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Using TXP Tags within Stylesheets

Did you folks try out Ako’s new plugin?


Steve

Offline

#29 2006-06-28 16:40:54

rloaderro
Archived Plugin Author
From: Costa Rica
Registered: 2006-01-05
Posts: 190
Website

Re: Using TXP Tags within Stylesheets

net-carver wrote:

Did you folks try out Ako’s new plugin?

You know i was looking for that plugin here and in textpattern.org but all I could find is this thread. Anyway it appears there is the same section problem with the plugin (which looks to be the same as this hack but in plugin form…).


Travel Atlas * Org | Start Somewhere

Offline

#30 2006-06-28 17:39:03

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Using TXP Tags within Stylesheets

Aeron,

would it be worth posting to Ako’s thread about this? (Just a thought)

PS> I didn’t post over there but I liked your work on the Del Oro site.


Steve

Offline

Board footer

Powered by FluxBB