Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-14 10:10:20

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

<txp:php> in article/title

I’m trying to get the current month (in PHP form it would be <?php echo date('F Y'); />) to be displayed in either the title or article body. Using the Textbook examples of:

<txp:php> phpinfo();
</txp:php>

and

<txp:php> echo “The current TXP category is: “ . category(array( ‘title’ => ‘1’, ‘link’ => ‘1’, ‘wraptag’ => ‘div’ ));
</txp:php>

within the article body gives me a parsing syntax error: syntax error, unexpected '<' in /var/www/sitepath/textpattern/publish/taghandlers.php(3089) : eval()'d code on line 2 & Parse error: syntax error, unexpected '&' in /var/www/sitepath/textpattern/publish/taghandlers.php(3089) : eval()'d code on line 2 respectively, but nothing else to go on. Are there restrictions on the placing of where <txp:php> can be used, or am I missing something obvious (hopefully the latter…)?

Thanks in advance :)

Edit: added second error.

Last edited by gaekwad (2009-05-14 10:11:42)

Offline

#2 2009-05-14 10:25:14

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

Re: <txp:php> in article/title

Try

<txp:php>echo date('F Y'); </txp:php>


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 2009-05-14 10:30:26

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: <txp:php> in article/title

colak wrote:

Try
<txp:php>echo date('F Y'); </txp:php>

Hi, colak. Thank you for your suggestion – unfortunately, I get a similar error: Parse error: syntax error, unexpected $end, expecting T_STRING or T_VARIABLE or '$' in /var/www/sitepath/textpattern/publish/taghandlers.php(3089) : eval()'d code on line 1 when I try this in an article context.

TXP 4.0.8 (r3085) with PHP 5.2.6-3ubuntu4.1, for info. All diagnostics pass, except for DNS (I’m localhosting).

Edit: <txp:php>echo date('F Y'); </txp:php> does work outside of the article body context, say in a sidebar, for example. So maybe it’s not happy in an article context after all…

Thanks again, colak.

Last edited by gaekwad (2009-05-14 10:32:31)

Offline

#4 2009-05-14 10:39:05

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: <txp:php> in article/title

You’d probably have to escape Textile:

==<txp:php>echo date('F Y'); </txp:php>==

Offline

#5 2009-05-14 10:41:00

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: <txp:php> in article/title

wet wrote:

You’d probably have to escape Textile:
<txp:php>echo date('F Y'); </txp:php>

And that’s it :) i was missing something obvious. Thank you, wet – greatly appreciated.

Last edited by gaekwad (2009-05-14 10:41:15)

Offline

#6 2009-05-14 10:44:32

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: <txp:php> in article/title

As an extension to my original query, is it possible to have <txp:php>echo date('F Y'); </txp:php> in the article title, or is that parsed in a different way? Both raw code and escaped Textile-proof instances just spit out the characters rather than the date.

Sorry for being a pain/pedant about this – I looked around and couldn’t see it covered already.

Thanks again :)

Offline

#7 2009-05-14 10:48:14

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: <txp:php> in article/title

<txp:title> does no parsing.

Offline

#8 2009-05-14 11:03:51

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: <txp:php> in article/title

wet wrote:

<txp:title> does no parsing.

Thanks again, wet – appreciate it :)

Offline

Board footer

Powered by FluxBB