Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-10 13:48:17

katasta
New Member
From: germany
Registered: 2005-05-30
Posts: 4

parse txp tags before php code

i am sure there is an easy solution for my problem, and i tried finding an answer by browsing and searching the archives, but i still couldn’t find what i need.

i have some php code, and depending on several conditions i want different forms to be included. my current code looks like this:

<code><?php
if($_GET && !empty($_REQUEST[‘oa’])) { echo $_REQUEST[‘oa’]; echo “<txp:output_form form=“order”>”;
} elseif ($_GET && empty($_REQUEST[‘oa’])) { echo “Please choose a product.”; echo “<txp:output_form form=“product”>”;
} else { echo “<txp:output_form form=“product”>”;
}
?>
</code>

but the txp tag doesn’t get parsed before the php code. how am i able to do so?

Last edited by katasta (2005-10-10 13:49:41)

Offline

#2 2005-10-10 14:14:41

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

Re: parse txp tags before php code

Stop using < ?php ?> and instead use <code><txp:php></txp:php></code>.

Offline

#3 2005-10-10 14:16:32

katasta
New Member
From: germany
Registered: 2005-05-30
Posts: 4

Re: parse txp tags before php code

doesn’t work that way either.

Offline

#4 2005-10-10 15:18:56

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: parse txp tags before php code

Don’t know if this is related to it’s not working, but the txp tag is not properly closed:

<txp:output_form form="product" /><br />
And if the form happens to be an article form you need to use <txp:article form="product" />.

Offline

#5 2005-10-10 20:28:41

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: parse txp tags before php code

Don’t try and mix Txp tags and PHP like that. Call the function itself.

All Textpattern tags are powered by functions of the same name. They accept two optional arguments. The first argument is an array of all the attributes. The second is the contents of a wrapping tag (not all tags make use of this wraptag functionality)..

To do the original code within the first post, you’d do:

if (gps('oa'))
{
	echo output_form(array('form' => 'order'));
}

else
{
	echo 'Please choose a product.'.output_form(array('form' => 'product'));
}

Clear as mud?

Last edited by Mary (2005-11-22 02:12:39)

Offline

#6 2005-11-22 00:58:49

gb
New Member
From: Buenos Aires, Argentina
Registered: 2005-11-19
Posts: 4

Re: parse txp tags before php code

> mary wrote:

> Don’t try and mix Txp tags and PHP like that. Call the function itself.

Hello Mary, i think this is usefull for me too, but i cant get the code at pastebin, could you please paste it here or even explain the solution??
thanks

gb

Offline

#7 2005-11-22 02:13:09

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: parse txp tags before php code

I’ve updated my post. :)

Offline

#8 2005-11-22 13:00:06

gb
New Member
From: Buenos Aires, Argentina
Registered: 2005-11-19
Posts: 4

Re: parse txp tags before php code

Thanks Mary i ve implemented this, but i couldnt make it work correctly.
i am using a plugin called jmc_event_manager. In a form i am trying to filter events that have the same date that a variable i am posting in the url (called dia) with this format DDMMYYYY (today is 22112005), the txp tag to get event date is

<txp:jmc_event_time php_date="jnY" />

so i use:

<code>
<txp:php>
if ( $_GET[dia] == jmc_event_time(array(‘php_date’ => ‘jnY’))){
echo ‘<li>
<txp:jmc_event_time php_date=“jnY” />
<h3><txp:jmc_event_name /></h3>
<ul>
<li class=“venue”>
<txp:jmc_venue form=“jmc_venue_form” />
</li>
<li class=“date”><txp:jmc_event_time php_date=“l jS F” /></li>
<li class=“time”><txp:jmc_event_time php_date=“H:i” /></li>
<li class=“price”><txp:jmc_event_price /></li>
<li class=“otherbands”><txp:jmc_event_otherbands /></li>
<li class=“other”><txp:jmc_event_otherinfo /></li>
</ul>
</li>’;
}
</txp:php></code>

but i get all events dates as 31121969 when called from jmc_event_time(array('php_date' => 'jnY')), so it looks like that php dont have enough data to get the date when executed…
do you have any idea how to solve this??
thanks

gb

Last edited by gb (2005-11-22 13:49:51)

Offline

#9 2005-11-22 22:12:10

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: parse txp tags before php code

I’m not familar with the plugin, so I took a look at the function in question. I’m afraid you can’t use it particular way you’re trying. You’ll need to contact the plugin author to find out if and how you can achieve this.

Offline

Board footer

Powered by FluxBB