Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-21 17:51:51

goncourt
Member
From: Dortmund/Germany
Registered: 2005-03-27
Posts: 24
Website

resolved: Problem with txp:posted and php-script

Hi,

I hope not to bore you with a special php-problem or my bad english.

On my site the posted-date of an article gets transformed to the french revolution calendar by a php-script, so instead of 2006-11-21 the date is Le I Frimaire de l’an CCXV.

This script worked fine till I updated textpattern to 4.0.4, if not even longer.
The same script on a pure php-example-file works without any error.
The problem must concern the way textpattern integrates this script with its own parameters.

In each article the necessary function is called that way:

<txp:php>$dat = “<txp:posted />”; $datum = new repDat($dat); </txp:php>

It calls the class “repDat()” once defined on the top of the page template.

But the result is in any time “Le XIII Nivôse de l’an CLXXIX instead of the correct result, for e.g. “Le I Frimaire de l’an CCXV.
That means, any time the date overgiven to the php-class is (or rather seems to be, if my script doesn’t fool me) 1970-01-01 (the begin of the unix-time I guess).

I tried some ways to understand what happens:
  • if I insert an “$dat = ‘<txp:posted />’; echo $dat;”, just to test its value, the code outputs the right date “2006-11-21” – that means the right date exists,
  • if I change the same example into “echo ‘<txp:posted />’;” the right date appears, too.
  • Even if I write clearly “$datum = new repDat(‘2006-11-21’)” the script produces a correct result. This way to call the class and to build a new object with it works fine.
  • Maybe a type problem? No: strval(‘<txp:posted />’) didn’t change anything
Conclusion:
  1. $dat = ‘<txp:posted />’; generates “2006-11-21” correctly as a string,
  2. $datum = new repDat(“2006-11-21”); outputs the correct “I Frimaire de l’an CCXV”;
  3. but $dat = ‘<txp:posted />’; $datum = new repDat($dat); doesn’t work.

Only when I give the value of the date-form as a parameter, textpattern doesn’t understand anymore anything and resets to the unix-start-date.

How can this be? Once again: with the former txp-version the script worked fine.

Last edited by goncourt (2006-11-21 19:13:27)

Offline

#2 2006-11-21 19:04:15

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

Re: resolved: Problem with txp:posted and php-script

You can’t use <txp: …> tags inside <txp:php> … </txp:php>

Try this:

<txp:php>$datum = new repDat(posted(array()));</txp:php>

Last edited by ruud (2006-11-21 19:05:14)

Offline

#3 2006-11-21 19:12:51

goncourt
Member
From: Dortmund/Germany
Registered: 2005-03-27
Posts: 24
Website

Re: resolved: Problem with txp:posted and php-script

Great: Long description of the problem, short and efficient answer!

Thanks very much!

Offline

Board footer

Powered by FluxBB