Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-04-06 05:39:11

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

Re: Add php within an article

Ok, here’s the result

The php written in a page (the skeleton with all the html) works perfectly. (Allow php in pages is set to yes.)

The php within an article gives me the error were trying to solve.

If I do not allow php in an article, the error disapear.

If I do not allow php in an article, but allow raw php, I get a similer error, but worse. The page goes completely white with the line :
Parse error: syntax error, unexpected ‘>’ in /home/…/textpattern/publish.php(1137) : eval()’d code on line 35

(The other error didn’t affect the website design, i was only displying the error when the “1” should have been.)

Last edited by Gimpy (2009-04-06 05:40:14)

Offline

#14 2009-04-06 05:47:00

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

Re: Add php within an article

Allow php in articles set to yes
Allow raw php set to no

Article form content.

<txp:php> echo “1”; </txp:php> is the correct code for that configuration.

How this may behave without some surrounding content isn’t something I’ve tested.

Offline

#15 2009-04-06 05:50:26

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

Re: Add php within an article

That’s exactly what I’ve got now, and it still give me the error message.

It should work fine without any surrounding content.

Thanks for your help anyways.

I’m going to sleep, since it’s 1h50am here :P I’ll be back tomorrow.

Offline

#16 2009-04-06 05:53:48

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

Re: Add php within an article

Me to.

Offline

#17 2009-04-06 08:39:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Add php within an article

Just in case you’ve not tried it and you’re embedding PHP directly in an article, set the Advanced Options->Article Markup to Leave text untouched. I’ve had it sometimes where I get similar syntax errors in PHP executed in an article, probably due to Textile getting confused. Don’t worry about the Raw PHP setting — leave it off — and use <txp:php>...</txp:php> tags.

Alternatively put a couple of spaces in front of your opening <txp:php> tag, or surround the tags with double equals signs to turn off textile processing, e.g

==<txp:php>echo "1";</txp:php>==

Finally, if all that fails, put the PHP in a form and use <txp:output_form form="my_php" /> instead. That’ll work fine.

Last edited by Bloke (2009-04-06 08:40:06)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#18 2009-04-06 08:42:27

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Add php within an article

You are using the code with in article, right? And you have Textile on, right?

So, well, you obviously need to escape the Textile markup or else it fucks it all up by using Textile inside your php tags.

For example, single line:

==<txp:php> /* Single line */ </txp:php>==

Multi-lines:

notextile. <txp:php> /* Multi line */ </txp:php>

Or hard-block:

notextile.. <txp:php> /* Multi line */ </txp:php>

 p. Textiled paragrap, escaped ends.

And so on.

Edit. Bloke. Faster. Damn.

Last edited by Gocom (2009-04-06 08:43:23)

Offline

#19 2009-04-06 12:46:19

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

Re: Add php within an article

Sweet. It works perfectly when there’s double equals in front and at the end.

Thank you very much !

<txtp:php>, shouldn’t automatically tell textpattern, that what’s coming isn’t regular text ? Anyways, it works now, so I can go forward.

Thanks again to everyone!

Offline

Board footer

Powered by FluxBB