ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using tag value as nested parameter

May 18, 2010 1:09pm

Subscribe [3]
  • #1 / May 18, 2010 1:09pm

    dsloan

    48 posts

    I am using nested tags, and wish to use a tag value returned by the initial tag pair, as a parameter value to pass to the nested tag pair. I’ve included the code below - this uses a plugin, but that is irrelevant I believe, since all I’m concerned about is how to use the tag value.

    {exp:rentpro:get_property id='{segment_3}'}
        <div><strong>{address1}</strong> - {town} {property_id}</div>
    
        {exp:rentpro:get_property_images id="{property_id}"}
            {image_name}<br>
        {/exp:rentpro:get_property_images}
    
    {/exp:rentpro:get_property}


    The first line containing the {address1}, {town} and {property_id} tags works/displays fine, so the plugin is returning the correct data - it’s just using this in the subsequent get_property_images call that doesn’t work.

    This syntax seems to work if I use a “native” EE tag, e.g. {segment_3} (which will work in this instance), but not if I use a “custom” tag name, e.g. {property_id}

    It also works ok if I simply supply the ID value explicitly, eg. id=“123”.

    But it doesn’t pick up the value from the {property_id} tag.


    This is similar to a snippet from the EE user documentation at http://expressionengine.com/public_beta/docs/development/module_tutorial.html

    {exp:channel:entries limit="10"}
    {title}
                
    {exp:download:entries entry_id="{entry_id}"}
    {file_title} - {file_download}
    {/download:entries}
    
    {/exp:channel:entries}

    I would have thought this was a common enough occurence?

    Thanks,
    Diarmid

  • #2 / May 18, 2010 2:41pm

    Wouter Vervloet

    758 posts

    Nested tags (when they are the same tag) don’t work. Just like you can’t use 2 nested channel:entries tags…

    One solution would be to embed a template with the nested tag in it.

    {exp:rentpro:get_property id='{segment_3}'}
      <div><strong>{address1}</strong> - {town} {property_id}</div>
      {embed='embeds/nested_property' property_id='{property_id}'}
    {/exp:rentpro:get_property}

    And the ‘embeds/nested_property’ template:

    {exp:rentpro:get_property_images id="{embed:property_id}"}
      {image_name}<br>
    {/exp:rentpro:get_property_images}

    Since embedded templates are rendered separately from their parent template, this will work.

    Greetz,
    Wouter

    [ EDIT ]
    Hmmm… Not until after I had posted it, I noticed that they weren’t the same tags you’re using.

    Could you try adding parse=‘inward’ to the rentpro:get_properties tag? That might solve your problem.

  • #3 / May 18, 2010 2:59pm

    dsloan

    48 posts

    Thanks Wouter - parse inward worked a treat!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases