Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-07-02 02:38:49

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Parsing php in section pages

<txp:php>
    ...
    global $dtstart;
    global $dtend;
    $dtstart = strftime('%Y%m%dT',$thisarticle['expires']) . $starthours . 'Z'; 
    $dtend= strftime('%Y%m%dT',$thisarticle['expires']) . $endhours. 'Z';
</txp:php>

and

<div class="vevent span-3 last"> <a class="url" href="<txp:permlink />"></a> <abbr class="dtstart" title="<txp:php>echo $dtstart;</txp:php>">August 01, 2010 - 21:00</abbr> <abbr class="dtend" title="<txp:php>echo $dtend;</txp:php>">23:00</abbr>

result:

<txp:php>
		Tag error: <txp:php> -> Notice: Undefined variable: dtstart  on line 1
	</txp:php>
	<txp:php>
		Tag error: <txp:php> -> Notice: Undefined variable: dtend  on line 1
	</txp:php>

Where am I messing up this time? sigh
Thanks in advance.


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#14 2010-07-02 06:45:43

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,000
Website GitHub

Re: Parsing php in section pages

any better when you put <txp:php>global $dtstart; echo $dtstart;</txp:php>?


TXP Builders – finely-crafted code, design and txp

Offline

#15 2010-07-02 06:51:05

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Parsing php in section pages

What about this:

global $variable;
$variable['dtstart'] = strftime('%Y%m%dT',$thisarticle['expires']) . $starthours . 'Z';

Last edited by Timid&friendly (2010-07-02 06:52:04)


I think, therefore I AM, … … er … I think :-?

Offline

#16 2010-07-02 06:55:10

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Parsing php in section pages

JanDW wrote:

Where am I messing up this time? sigh
Thanks in advance.

You need to access the global from the global scope. The variable is not accessible inside the function. For example:

<txp:php>
	global $dtstart; /* Back in the biz */
	echo $dtstart;
</txp:php>

Or using the $GLOBALS superglobal array which contains all the variables defined in the global scope:

<txp:php>
	echo $GLOBALS['dtstart'];
</txp:php>

Offline

#17 2010-07-02 12:37:37

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Parsing php in section pages

ah, thanks for making me understand, guys.


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

Board footer

Powered by FluxBB