Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-03 00:32:33

shilmy
Member
Registered: 2006-04-29
Posts: 49

How to use PHP code in Article?

Hello,

I always got parsing error when I try to put PHP code in the article. Even for simplest php code, like this

<txp:php>echo ‘Hello world’; </txp:php>

Can somebody help?

Regards,
Sjarief

Offline

#2 2007-08-03 03:19:03

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

Re: How to use PHP code in Article?

I would start by checking your preference settings under the admin tab

Preferences > Advanced > Publish “Allow PHP in Articles”

Offline

#3 2007-08-03 03:25:17

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: How to use PHP code in Article?

not sure but i believe you also have to select Article Markup under Advanced Options in the article as “Leave text untouched” or else it will be parsed as <txp:php>echo &#8216;Hello world&#8217;;</txp:php>

Offline

#4 2007-08-03 07:24:56

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to use PHP code in Article?

Both option have been re-checked but I still got parsing error message.

Here is the message:

Parse error: parse error, unexpected ‘&’ in C:\xampplite\htdocs\txp405\textpattern\publish\taghandlers.php(2745) : eval()’d code on line 1

Offline

#5 2007-08-03 07:30:46

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How to use PHP code in Article?

Add a space before the <txp:php> part, save the article again, then see if it works

Offline

#6 2007-08-03 13:57:25

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to use PHP code in Article?

The result is still the same.

I’ve try this on my local computer, my hosting, try both 4.0.4 and 4.0.5 version, the result is still the same.

So far I’ve only use PHP successfully on pages and forms, not article

Offline

#7 2007-08-03 14:00:07

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: How to use PHP code in Article?

are you sure “Leave text untouched” is selected for the article? when i leave it as the default (textile), i get the exact same parsing error. when i put it on ‘leave text untouched’ the php is parsed correctly

not sure if php is supposed to not work while in textile mode shrug

Last edited by iblastoff (2007-08-03 14:00:52)

Offline

#8 2007-08-03 14:23:26

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to use PHP code in Article?

Yes, I’m positively sure. I try both setting, textile and leave text untouched, the result still the same.

Ok, I’ll download again and will try to fresh install txp 4.0.5 and try this again and will tell you the result.

Offline

#9 2007-08-03 15:01:02

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: How to use PHP code in Article?

Probably you already did it but… did you remember to put before your <txp:php> tag the notextile tag ?
Try this:

notextile..  <txp:php>

Offline

#10 2007-08-04 10:32:01

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How to use PHP code in Article?

FAQ and FAQ

Offline

#11 2007-08-04 12:00:41

shilmy
Member
Registered: 2006-04-29
Posts: 49

Re: How to use PHP code in Article?

Sorry it’s all my mistake.

This problem should solve by selecting Article Markup under Advanced Options in the article as “Leave text untouched” just like iblastoff suggestion.

What I did before is doing the same in Excerpt Markup, not Article Markup. I just do not realize it.

Sorry if this cause you a trouble.

Thanks for all your help.

Sjarief

Offline

Board footer

Powered by FluxBB