Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-04-17 18:53:26

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

txp:php and custom fields

I have some php include code that looks like this on an older version of TXP:

<?php include('http://www.domain.com/code.php?file=<txp:custom_field name="place" />'); ?>

I want to the site to a new version of TXP, which means using the txp:php tag, but it isn’t working. Here’s what I’ve tried:

<txp:php> include('http://www.domain.com/code.php?file=<txp:custom_field name="place" />'); </txp:php>

If I replace <txp:custom_field name=“place” /> with simply the place name, it works. That isn’t a solution, however… there are two thousand pages that use the custom field to define “place”.

How are custom fields used within <txp:php> tags?

Offline

#2 2015-04-17 19:05:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: txp:php and custom fields

Hi, rah_external should be of help


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2015-04-17 19:10:28

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: txp:php and custom fields

You should parse the tag, try

<txp:php> include(parse('http://www.domain.com/code.php?file=<txp:custom_field name="place" />')); </txp:php>

Offline

#4 2015-04-17 19:38:46

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: txp:php and custom fields

etc wrote:

You should parse the tag, try

Tried that – same result. The custom field just isn’t outputting inside <txp:php> tags.

colak wrote:

Hi, rah_external should be of help

I may not understand rah_external. I thought it was for outputting something from TXP to be used on another site. In my application, I’m inserting external html content into a TXP page. Will it do that?

Offline

#5 2015-04-17 19:41:02

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: txp:php and custom fields

What bout this?

<txp:php> include("http://www.domain.com/code.php?file=custom_field(array('name' => 'place'))"); </txp:php>

Offline

#6 2015-04-17 19:46:36

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: txp:php and custom fields

GugUser wrote:

What bout this?

Tried it (thank you). The custom field still doesn’t output.

Offline

#7 2015-04-17 20:01:44

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: txp:php and custom fields

towndock wrote #290104:

The custom field just isn’t outputting inside <txp:php> tags.

What do you get with

<txp:php> echo parse('http://www.domain.com/code.php?file=<txp:custom_field name="place" />'); </txp:php>

Edit: make sure you are in the article context (inside <txp:article /> or in some form). And it might be

<txp:php> include(urlencode(parse('http://www.domain.com/code.php?file=<txp:custom_field name="place" />'))); </txp:php>

Last edited by etc (2015-04-17 20:09:14)

Offline

#8 2015-04-17 20:31:06

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: txp:php and custom fields

etc wrote:

What do you get with

I got exactly what it was supposed to be. So I went back to your example:

 <txp:php> include(parse('http://www.domain.com/code.php?file=<txp:custom_field name="place" />')); </txp:php>

It works! (I must have fat fingered something on the initial try). Thank you much…

Offline

Board footer

Powered by FluxBB