Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 12,505
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.

Hire 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