Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
<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
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
Re: <txp:php> not working in articles.
Also, is php allowed in articles? Check your preferences.
Offline
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
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
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
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
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
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
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
Pages: 1