Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-06 04:42:17

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Add php within an article

I want to write some php code within my article.

1. I’m using Textpattern · 4.0.8
2. “Allow PHP in pages”, “Allow PHP in articles” and “Allow raw php”, are all set to yes.

PHP code must be both without opening and closing PHP tags, and enclosed within txp:php tags.”

3. I’ve written it this way :

<txp:php> echo “1”;
</txp:php>

How can I make this work ?

Thanks!

Offline

#2 2009-04-06 04:50:04

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

Not sure what you are asking.

<txp:php>  echo “1”;
</txp:php>

does work.

Offline

#3 2009-04-06 04:52:05

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Re: Add php within an article

Well i’ve got an error saying :

Parse error: syntax error, unexpected ‘<’ in /home/…/textpattern/publish/taghandlers.php(3089) : eval()’d code on line 1

Last edited by Gimpy (2009-04-06 04:52:32)

Offline

#4 2009-04-06 04:59:21

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

Hmm, copied and pasted what you have actually posted here and it returns “1” in my article form nicely, that is with the quotes if that is what you intend – might try copying the code here back to your article form.

Offline

#5 2009-04-06 05:02:10

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Re: Add php within an article

Yup, done that, but with no success. It’s weird.

Offline

#6 2009-04-06 05:03:59

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

Does the error persist if you remove the code in question altogether?

Offline

#7 2009-04-06 05:06:29

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Re: Add php within an article

if I remove “</txp:php>”, the error disapear, but nothing it displayed.

In the source code, i’ve got a lonely <p> where “<txp:php> echo “1”;” should be.

Offline

#8 2009-04-06 05:09:51

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

Could you post your code in a little larger context, say the entire article form if that is where you are using it.

Offline

#9 2009-04-06 05:17:06

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Re: Add php within an article

Well my article is completely blank. It only has a title which is “test”.

In the body, i’ve written the code I wrote in my first post.

When looking at the article when published, i’ve got this error message : Parse error: syntax error, unexpected ‘<’ in /home/…/textpattern/publish/taghandlers.php(3089) : eval()’d code on line 1

I don’t know what to write as a larger context. That’s pretty much all there is to say.

Offline

#10 2009-04-06 05:24:29

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

If you use an unclosed tag this way: “<txp:php> echo “1”;” TXP will look for the closing tag and the response is a blank. The lonely paragraph tag is probably a textile response. What you have posted here should work in an article form, and it does anywhere I use it. I can’t reproduce what you are seeing, so we are missing something obvious I would suspect.

Given that you have settings for raw php set to yes, try <?php echo “1”; ?> , if that works – set it to no and try the TXP tags.

Last edited by rsilletti (2009-04-06 05:31:59)

Offline

#11 2009-04-06 05:30:33

Gimpy
New Member
Registered: 2009-04-06
Posts: 9

Re: Add php within an article

It should work indeed. There’s nothing simplistic then that.

I’ve checked again, and the advance settings regarding php in an article or a page in the admin are all set to yes. It’s also a completely new install and didn’t get any error message while installing it.

I just can’t see where the error could be. It’s like if it didn’t like the closing tag, but I don’t see why.

Offline

#12 2009-04-06 05:33:36

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Add php within an article

Given that you have settings for raw php set to yes, try <?php echo “1”; ?> , if that works – set it to no and try the TXP tags.

Offline

Board footer

Powered by FluxBB