Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-24 17:20:10

dingoboy
Member
Registered: 2006-09-07
Posts: 48

4.0.4 problem with <txp:php>

Pardon me if this is a repost.

When I installed Textpattern 4.0.4 I experienced trouble, using manually typed in PHP in my pages.

Because I didn’t use the <txp:php> ... </txp:php> initiation/closing but the regular <?php ... ?>, I got a warning. Fair enough – the site’s production status was production_test. However, the warning didn’t disappear when production status was set to production_live.

Moreover, when I applied the new method for initiating/closing my PHP code (<txp:php> ... </txp:php>), I got several errors:

Parse error: syntax error, unexpected $end in /path/to/my/textpattern/publish/taghandlers.php(2681) : eval()'d code on line 3 ...

And all the different chunks of design, which my PHP code was only supposed to spit out under certain circumstances, was suddenly included.

I found no solution to this problem and I had to change back to 4.0.3 because of this. This also means, I cannot show you what I’m talking about, since the problem doesn’t occur in 4.0.3.

Offline

#2 2006-10-24 17:29:24

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

Re: 4.0.4 problem with <txp:php>

If you can show us the bits of code you had between <?php ... ?> and how you tried to translate them to <txp:php> ... </txp:php>, we can probably help you figure out the problem.

Offline

#3 2006-10-24 17:44:56

dingoboy
Member
Registered: 2006-09-07
Posts: 48

Re: 4.0.4 problem with <txp:php>

Something like this:

<txp:php>

if ($_SERVER['REQUEST_URI'] == '/section/666/oh-god-help-me') {

</txp:php>

<h3>Special stuff</h3>

<txp:article_custom section="foo" sortby="title" sortdir="asc" category="bar" form="lofi" limit="50" listform="resume" />

<txp:php>

}

</txp:php>

————————————-

As you see, the PHP is interrupted by the content that is to be included if the URI is equal to /section/666/oh-god-help-me. I guess the problem could be solved by letting PHP print the content, instead of interrupting it — but this should be (made) possible. :)

Earlier I just applied the now deprecated <?php and ?> as mentioned. Nothing else was changed.

Last edited by dingoboy (2006-10-24 17:47:28)

Offline

#4 2006-10-24 18:32:18

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

Re: 4.0.4 problem with <txp:php>

Read the FAQ:Using PHP code in Textpattern
Especially the section ‘Escaping to HTML

You’d have to something like this:

<txp:php>
  if ($_SERVER['REQUEST_URI'] == '/section/666/oh-god-help-me') {
    echo '<h3>Special stuff</h3>';
    echo parse('<txp:article_custom section="foo" sortby="title" sortdir="asc" category="bar" form="lofi" limit="50" listform="resume" />');
  }
</txp:php>

Last edited by ruud (2006-10-24 18:33:22)

Offline

#5 2006-10-24 18:37:58

dingoboy
Member
Registered: 2006-09-07
Posts: 48

Re: 4.0.4 problem with <txp:php>

Thanks, ruud. :-)

This is – however – not a very sattisfying solution in my oppinion. I’ll request a functionality similar to the regular way of escaping PHP.

Offline

#6 2006-10-25 07:06:08

amordecosmos
Plugin Author
From: London (Hometown: Vancouver)
Registered: 2004-08-03
Posts: 114
Website

Re: 4.0.4 problem with <txp:php>

My problem with <txp:php>

I’m trying to use the Upcoming.org API with TXP. The following is their sample code with <?php> changed to <txp:php>:

<txp:php>
       require_once "Services/Upcoming.php";
       //
       //Set the content type to be plain text, for easier debugging
       //
       header("content-type: text/plain");
       //
       //Create new client
       $client = &new Services_Upcoming();
       //
       //Set API key
       $client->setApi([Upcoming API]);
       //
       //call event.Search()
       $events = $client->event_search("The Big Day Out"); //Search for events that match "The Big Day Out"
       //
       //print matches
       print_r($events);
       //
       //Let's try events based in a city. This is one way, like 43things uses.
       $events = $client->event_search("Adelaide"); //Search for events that match "Adelaide"
       //
       //print matches
      print_r($events);
       //
       //Let's try events based in a state.
       $events = $client->event_search(null,null,331); //Cover all of "South Australia" (331)
       //
       //print matches
       print_r($events);
</txp:php>

NOTE: Apparently PEAR is required. (I use textdrive so it should be there) and where it says Upcoming API, a unique key is placed. (I have it but making it public is bad security. I’ll post/email if needed.)

Any ideas?

- ad

Last edited by Sencer (2006-10-25 07:31:06)

Offline

#7 2006-10-25 07:32:42

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: 4.0.4 problem with <txp:php>

Set production status to debugging (in preferences) and follow the error-messages.

Last edited by Sencer (2006-10-25 07:33:37)

Offline

Board footer

Powered by FluxBB