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.

Use value of tag as a tag inside Rest add-on.

August 29, 2012 1:24pm

Subscribe [1]
  • #1 / Aug 29, 2012 1:24pm

    Jason Varga

    26 posts

    This is a bit of an inception-esque scenario.

    I’m trying to parse some data from a CSV using the Rest add-on.
    In this addon, to display the data in the template, you use the header cell as the tag.

    However, I’m trying to dynamically get the header cells from a Playa tag.
    The header cells are URL titles of corresponding entries.

    So my template looks something like this:

    <table>
      <thead>
        {playa_field}
          <th>{title}</th>
        {/playa_field}
      </thead>
      {exp:rest url="path_to_csv.csv" format="csv"}
      <tr>
        {playa_field}
        <td>{{url_title}}</td>
        {/playa_field}
      </tr>
      {/exp:rest}
    </table>

    The {{url_title}} is where the issue lies. (Obviously double brackets like that won’t work, it’s just an example).
    What I really need is the value of the {url_title} (from the playa tag) to be in its own variable in order to be parsed by the {exp:rest} tag.

    So if the {url_title} is “my-entry-title”, I somehow need the tag to be {my-entry-title}.

    My CSV would look something like this:

    my-entry-title,another-url-title,yet-another-url-title
    cell1value,cell2value,cell3value

    Hopefully this makes some form of sense to someone.
    Thanks!

     

  • #2 / Aug 29, 2012 2:46pm

    Jason Varga

    26 posts

    I got this working by using preload_replace vars, since they are parsed early.

    {preload_replace:cell_1="{playa_tag limit='1' offset='0'}{url_title}{/playa_tag}"}
    {preload_replace:cell_2="{playa_tag limit='1' offset='1'}{url_title}{/playa_tag}"}
    etc

    and

    {exp:rest ...}
      {{cell_1}}
    {/exp:rest}

    as per advice from @kristengrote

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

ExpressionEngine News!

#eecms, #events, #releases