Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-07 18:38:14

cap_nemo
Member
Registered: 2005-04-20
Posts: 33
Website

4.0.2 Error page PHP parsing bug

I’ve been having an issue with my default error page in the new 4.0.2 version, the page doesn’t seem to be parsing my php include correctly. It’s also not displaying the correct stylesheet. Check out this link and then view the source.

You can see that the actual php code is being displayed and then you can also see that it’s not displaying the TXP stylesheet link correctly.

Any help would be much appreciated, thanks!

(Edit: I’ve marked the thread as resolved. -Mary)

Offline

#2 2005-11-07 21:05:22

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error page PHP parsing bug

<?php include_once($_SERVER[“DOCUMENT_ROOT”].”/common/nav.php”); ?>@

FAQ.


Alex

Offline

#3 2005-11-10 18:19:05

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: 4.0.2 Error page PHP parsing bug

Ok… I’m having a similar problem. Zem, your response doesn’t really state why PHP is not being parsed in the 404 page templates. I noticed that some <txp:php></txp:php> code snippents work but when you try to call a function it does not.

I tried converting all of my normal php code in my forms using the <txp:php></txp:php> technique but I get errors when trying to call a function(yes the function does exist and is being defined). The technique does not allow for the creation or calling of a function. For example when I put this into my footer form:

<txp:php>
SideBar();
</txp:php>

I get taghandler errors.

Is there a reason why the error page template does not support php like all of the other page templates?

Offline

#4 2005-11-10 20:44:15

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error page PHP parsing bug

yes the function does exist and is being defined

How did you confirm this?

I get taghandler errors.

Care to tell us what they are?


Alex

Offline

#5 2005-11-10 20:59:19

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: 4.0.2 Error page PHP parsing bug

The function call works perfectly if I do not use <txp:php></txp:php> (as long as it’s not in the error page template). If I change <?= SideBar(); ?> to <txp:php> SideBar(); </txp:php> then I get the error below.

Here’s the error:
Fatal error: Call to undefined function: sidebar() in …/taghandlers.php(1671) : eval()’d code on line 1

This could all be resolved if the error template could use php like the other templates.

Last edited by qrayg (2005-11-10 21:00:13)

Offline

#6 2005-11-10 21:15:50

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

Re: 4.0.2 Error page PHP parsing bug

Is there a reason why the error page template does not support php like all of the other page templates?

Yes, it’s broken, error-rone, had coutner-intuitive results most of the time and was deprecated months ago in favor of the txp:php tags. The only reason why it wasn’t completely removed was to not break backwards-comaptibility (somebody updating their site and stuff suddenly breaking).

With txp:php each code-section is evaluated individually. It’s possible that you are calling the function before it is being defined. Can you post or better yet, link to the (source of the) complete content/context of what you are using?

Offline

#7 2005-11-10 21:16:40

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error page PHP parsing bug

Fatal error: Call to undefined function: sidebar() in …/taghandlers.php(1671) : eval()’d code on line 1

That ought to be pretty clear: the function isn’t defined.

How and where are you defining the function? Presumably it’s not loaded when the error page is displayed.


Alex

Offline

#8 2005-11-10 21:55:12

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: 4.0.2 Error page PHP parsing bug

@Sencer
Thanks for the response. I appreciate it. Now I guess I need to figure out how to use the TXP PHP tags and get my functions to work. Here’s a simplified version of my default page template:

—-
<txp:output_form form="site-head" /> //My site header html
<txp:article />
<?php function SideBar() { ?>
Sidebar stuff goes here
<?php } ?>
<txp:output_form form="site-foot" /> //My site footer html. This contains the SideBar function call. As you can see the function is defined before the call. When I convert either the definition, the call or both to the <txp:php> tag style it throws the error stated in my previous post. I’m not putting <?php> in the <txp:php> tags.

Any ideas?

—-

Zem As stated before it works perfectly fine without the <txp:php></txp:php>@. The function is defined… that’s the issue here… why is it throwing an error when it shouldn’t be.

Last edited by qrayg (2005-11-10 21:56:12)

Offline

#9 2005-11-10 22:27:59

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

Re: 4.0.2 Error page PHP parsing bug

How are you converting this part to the nex syntax:

<? php function SideBar() { ?>
Sidebar stuff goes here
<? php } ?>

you can for example do (using heredocs ):

<code>
<txp:php>
function SideBar() { echo <<<EOD
Sidebar stuff goes here
lalala
blah
EOD;
}
</txp:php>
</code>

As I said, txp:php is evaluated by itself. So splitting up the “before” and “after” part in two different txp:php can’t work.

(btw: The function is not defined, you may not see an error message, maybe because of your production status being set to live, but the function is not being defined or you wouldn’t get that fatal error. ;) )

Offline

#10 2005-11-10 22:59:26

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: 4.0.2 Error page PHP parsing bug

<txp:php> doesn’t support HTML escaping. I’ll add a note to the FAQ.

If your SideBar() function merely outputs a static chunk of HTML, you’d be better off putting that HTML in a form and using txp:output_form.


Alex

Offline

#11 2005-11-10 23:19:19

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: 4.0.2 Error page PHP parsing bug

> Sencer wrote:
(btw: The function is not defined, you may not see an error message, maybe because of your production status being set to live, but the function is not being defined or you wouldn’t get that fatal error. ;) )

If it’s not defined then why does it output the function when I don’t use <txp:php> ???

I tried the heredocs thing and now it seems to work. Thanks for the tip.

@Zem
Sadly the content inside of the function is section specific article listings and each section has a unique set of code, otherwise I would have used the output_form method to begin with.

Offline

#12 2005-11-10 23:39:13

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

Re: 4.0.2 Error page PHP parsing bug

I tried the heredocs thing and now it seems to work. Thanks for the tip.

Great. :)

If it’s not defined then why does it output the function when I don’t use <txp:php> ???

I’ve been trying to explain it (twice), but I guess I can’t explain it well: if you switch in and out of a php script using the regular php-delimiters, then the php interpreters still executes it all at once. Using txp:php evaluates each piece of code by itself.

Offline

Board footer

Powered by FluxBB