Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2005-12-04 16:37:24
- garrettdimon
- Member
- Registered: 2005-04-12
- Posts: 11
Error Pages parsing PHP?
I’m using some embedded PHP to handle some cookie-based style switching. It seems to always work fine except on the error pages.
When I view source on my error pages, it appears as if the PHP was simply ignored. I imagine that given the fact it is an error page, simpler and static is probably better. I’ts not too big of a deal to just create static error pages, but I wanted to know if this was intentional before I did that.
Offline
Re: Error Pages parsing PHP?
Embedding php in txp is recommended to be done via <txp:php>echo "hi there";</txp:php>
Early versions of txp introduced the “regular” php-tag style embedding, however that results in more problems than it solves, that’s why we swtiched to the txp:
style tags. The older behaviour was only left in for backwards-compatibility, but was not re-implemented for new features (like error-pages).
Offline
#3 2005-12-04 17:20:09
- garrettdimon
- Member
- Registered: 2005-04-12
- Posts: 11
Re: Error Pages parsing PHP?
Great. Thanks.
Offline
#4 2005-12-04 17:27:52
- garrettdimon
- Member
- Registered: 2005-04-12
- Posts: 11
Re: Error Pages parsing PHP?
Actually, after trying to implement this, it’s ignoring the txp:php tags as well.
The php is currently contained in one form. Does it only get parsed if it’s in a page or an article?
(I do have php enabled in the configuration, and regular PHP tags are working in the form.)
Offline
Re: Error Pages parsing PHP?
I just tested it, and it is working in error_pages for me.
Take a look at the detailed explanation in the FAQ, especially the section at the end, where it says “escaping to html”.
If you can show use the exact code you’re trying to use (maybe using pastebin.com if you get trouble here), I can better explain what’s going wrong.
Offline
#6 2005-12-04 19:20:50
- garrettdimon
- Member
- Registered: 2005-04-12
- Posts: 11
Re: Error Pages parsing PHP?
Here is my form that is called in all of the pages…
http://pastebin.com/448595
Here is the HTML that is output…
http://pastebin.com/448593
Offline
#7 2005-12-04 22:06:22
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Offline
Re: Error Pages parsing PHP?
Yep, it’s due to scope problems. Those variables you are defining are always local to the code-block. You have explicitly set the global scope if you need to use them in different blocks. Or alternatively you can declare functions, instead of defining variables. (There are no scopes for function declarations, all functions always exist in the one, global, namespace).
Offline
#9 2005-12-05 02:46:38
- garrettdimon
- Member
- Registered: 2005-04-12
- Posts: 11
Re: Error Pages parsing PHP?
Thanks. I feel like a jackass for not reading the FAQ’s. :)
I appreciate the response, and everything is great now.
Offline
Pages: 1