Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-26 20:05:12

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

<txp:php> not working in articles.

OK…I have the settings in the admin prefs to allow PHP scripting, and I checked the permissions in admin_config.php
I’m getting the error below when I try to use <txp:php> in an article.

Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in /home/virtual/site151/fst/var/www/html/CMS/textpattern/publish/taghandlers.php on line 1525

Any help would be greatly appreciated.

Thanks.

Tom

(Edit: marked as resolved. -Mary)

Offline

#2 2005-10-26 20:34:10

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

Re: <txp:php> not working in articles.

  • Are you using any plugins?
  • Have you modified textpattern code in any way?
  • Are you using auto-prepends?
  • Have you embedded Textpattern into anything else?
  • Are you using output buffering in the php-code snippet?
  • Can you post the code snippet you’re trying to run; or do you even get the error for a simple echo “test”;?

Offline

#3 2005-10-26 20:41:52

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: <txp:php> not working in articles.

Also, is php allowed in articles? Check your preferences.

Offline

#4 2005-10-26 20:42:24

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> not working in articles.

Sencer,

Thanks so much for the quick response.

I haven’t modified textpattern in any way.

I get the error from a simple echo “test”; — the only thing I realized is that I’m call this article on a non-textpattern page.

I have the following code at the top of the page:

<?php define(“txpinterface”, “public”);
include ‘./CMS/textpattern/config.php’;
include $txpcfg[‘txpath’].’/publish.php’;
ob_start(‘parse’); ?>

I would bet that the ob_start(‘parse’); has something to do with this, but I’m not sure how to fix it.

Thanks,


Tom

Offline

#5 2005-10-26 20:44:48

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> not working in articles.

paularms,

Thanks for the response…I double checked all the prefs before I posted. Everything should be setup porperly.

Thanks,
Tom

Offline

#6 2005-10-26 21:02:28

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

Re: <txp:php> not working in articles.

I would bet that the ob_start(‘parse’); has something to do with this, but I’m not sure how to fix it.

You’re 100% correct. ;)
When the callback-function is executing, we can’t start any new buffers, but we are using them in different places in Textpattern, and one such place is for executing php. You’ll have to workaround that. For example use ob_start(); at the beginning (without passing a callback function). And at the end of your script you do
<code>
$output = ob_get_clean();
echo parse($output);
</code>
That way you end your output-buffer, before passing the return-value to parse().

Offline

#7 2005-10-26 21:21:47

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> not working in articles.

OK. so I could end the output buffer on my index.php before the “div” I’m using to display all the textpattern stuff that uses “txp:php” in articles, then I could start it again afterwards to parse any remaining tags on index.php . Does taghandlers.php end the output buffer it starts?

I’m a little bit over my head here, but persistent. : )


Tom

Last edited by renobird (2005-10-26 21:22:42)

Offline

#8 2005-10-26 21:58:46

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

Re: <txp:php> not working in articles.

No, you misunderstood me. You should replace:

ob_start(‘parse’); with ob_start(); in your above example-code. Then at the every end of your php-page/script, you insert the two lines I showed above. Functionally it is equivalent because both times parse() is called with all the stuff your script outputted, but the difference is, that in the first case (which doesn’t work), parse() is executing as a callback-function for the output-buffer, and in the second case it isn’t.

Offline

#9 2005-10-30 19:13:21

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> not working in articles.

Sencer,

Thanks again for assistance with this…It really helped me better understand how TXP works. I figured out another way around this issue using PHP outside of the article. Sometimes the easiest solutions are the hardest to see. : )

Cheers,
Tom

Offline

#10 2005-11-08 02:46:33

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: <txp:php> not working in articles.

Sencer,

So I ran into another instance where I needed to use <txp:php>, I changed the code as you suggested and it worked perfectly! Thank You. I Just wanted to update this topic incase anyone else ran across it.

Thanks Again,
Tom

Offline

Board footer

Powered by FluxBB