Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-05-01 09:31:36

phuture303
Member
Registered: 2008-09-14
Posts: 127

[SOLVED] <txp:yield> in <txp:php> for replacing different IDs

Hi,

I have several application forms which are embedded into my articles like this (each form has a different form_ID – see 3rd line):

<txp:php>
require("/website/12345/htdocs/matchform/machform.php");
$mf_param['form_id'] = 1;
$mf_param['base_path'] = 'http://example.com/matchform/';
display_machform($mf_param);
</txp:php>

I would like to put this into a form and then use and use and use it …, e.g.

<txp:output_form form="anmeldung">1</txp:output_form>

But I have problems to integrate <txp:yield> into the php-snippet (instead of the ID) without error-messages – don’t know how to spell it with “echo”, “parse” and “semicolons” so that the yield-tag is parsed correctly :-)

Any hints? Thanks a lot!
David :-)

Last edited by phuture303 (2011-05-01 12:21:10)

Offline

#2 2011-05-01 10:03:35

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: [SOLVED] <txp:yield> in <txp:php> for replacing different IDs

And, an additional question (would like to know both solutions :-)

Would this be possible with txp:variable?

  • Putting the form-ID into a custom_field name="formular_id"
  • Pulling this ID from the custom_field into a variable name="formular_id" which is placed in the article, followed by txp:output_form form="formular"
  • Replacing the static ID (“1”) in the PHP-snippet with the variable above.

I think this would be even more user-friendly. But as mentioned above, I have no idea how to parse the yield-tag or variable correctly in the PHP-code.

Thanks! :)
David

Offline

#3 2011-05-01 11:37:55

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [SOLVED] <txp:yield> in <txp:php> for replacing different IDs

<txp:php>
require("/website/12345/htdocs/matchform/machform.php");
$mf_param['form_id'] = yield();
$mf_param['base_path'] = 'http://example.com/matchform/';
display_machform($mf_param);
</txp:php>

Code is topiary

Offline

#4 2011-05-01 11:42:51

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [SOLVED] <txp:yield> in <txp:php> for replacing different IDs

phuture303 wrote:

Would this be possible with txp:variable?

Unless you otherwise want this value in a Txp variable (for example, to be able to use the if_variable tag), you could just use the custom field value directly.

E.g.,

<txp:output_form form="anmeldung"><txp:custom_field name="the_custom_field_in_question" /></txp:output_form>

Code is topiary

Offline

#5 2011-05-01 12:01:31

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: [SOLVED] <txp:yield> in <txp:php> for replacing different IDs

Hey Jeff,

thank you very much for your help! Didn’t know that’s THAT easy with the yield() :-)

With your help I even now understood how to integrate the value of a custom_field directly into this PHP-code:

<txp:php>
require("/website/12345/htdocs/matchform/machform.php");
$mf_param['form_id'] = custom_field(array('name'=>'formular-id'));
$mf_param['base_path'] = 'http://example.com/matchform/';
display_machform($mf_param);
</txp:php>

In my article I now have

<txp:output_form form="anmeldeformular"/>

and a custom_field name="formular-id", directly under the option whether application is possible or not (which makes the form “live” or not). It’s easier for my co-admins to use the custom_field instead of changing the form-id in between the two output_form tags.

Works perfectly now, many thanks!
David happy :-)

Offline

Board footer

Powered by FluxBB