Dynamic tags as arguments to dynamic tags

Hi all,

I've got one plug-in which provides a dynamic tag and we're developing *another* plug-in with another dynamic tag. We'd like to use this second tag as an argument to the first, but are running into trouble.

#TAG1 takes some parameters and feeds them to a template after some processing and #TAG2 looks up 'afieldname' in the database and returns the correct value.

#TAG2 works fine when used normally in a SPIP template, but when we pass it as an argument to #TAG1 like so:

  [(#TAG1{'afield', [(#TAG2{'afieldname'})]})]

#TAG1 outputs the generated PHP code which calls balise_TAG2_dyn() instead of the value. Do I need to modify my implementation of #TAG1 to evaluate its parameters before using them? Or is there something else at work here?

Thanks,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

#TAG1 outputs the generated PHP code which calls balise_TAG2_dyn() instead
of the value. Do I need to modify my implementation of #TAG1 to evaluate its
parameters before using them? Or is there something else at work here?

As ou have understood the "result" of a dynamic tag is php code that
will be eval()'d at the last moment.

You can probably do #TAG1{xxx, #INCLUDE{small squelette containing
#TAG2} }, because #INCLUDE forces evaluation.

-- Fil

Hi Fil,

Thanks for the suggestion.

On 22/04/2009, at 4:42 PM, Fil wrote:

#TAG1 outputs the generated PHP code which calls balise_TAG2_dyn() instead
of the value. Do I need to modify my implementation of #TAG1 to evaluate its
parameters before using them? Or is there something else at work here?

As ou have understood the "result" of a dynamic tag is php code that
will be eval()'d at the last moment.

You can probably do #TAG1{xxx, #INCLUDE{small squelette containing
#TAG2} }, because #INCLUDE forces evaluation.

Alas, it outputs the code of the #INCLUDE{}ed template instead. I'm going backwards! :slight_smile:

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

Alas, it outputs the code of the #INCLUDE{}ed template instead. I'm going
backwards! :slight_smile:

Ah. In fact you were right in your first suggestion. You need to
evaluate your arguments with interprete_argument_balise; see e.g.
public/balises.php

To retrieve the computed value of the second argument use:
$val = interprete_argument_balise(2,$p)

-- Fil