0

I'm trying to use a variable in a match for a stash get_list like so, but it doesn't appear to be working;

I'm setting an initial entry_id here for a place;

{exp:channel:entries
    channel="places"
    status="open"
    {global:channel_disable_basic}
}
{exp:stash:set name="place_id"}{entry_id}{/exp:stash:set}
{/exp:channel:entries}

Then I'm getting a list of events like so which contains an Event Venue as a custom field;

{exp:stash:set_list
    name="venue-events"
    parse_tags="yes"
    parse_conditionals="yes"
    parse_depth="3"
    save="yes"
    scope="site"
}
    {exp:calendar:cal
        calendar_id="4871"
        first_day_of_week="1"
        enable="custom_fields"
        date_range_start="today"
        date_range_end="+ 12 months"
        pad_short_weeks="n"
        dynamic="yes"
    }
        {stash:venue_event_title}{title}{/stash:venue_event_title}
        {stash:venue_event_venue}{cf_event_venue}{entry_id}{/cf_event_venue}{/stash:venue_event_venue}
    {/exp:calendar:cal}
{/exp:stash:set_list}

Then finally i'm using the 'place' entry_id above to match against the 'venue_event_venue';

{exp:stash:get_list
    name="venue-events"
    require_prefix="no"
    parse_tags="yes"
    parse_depth="3"
    match="#^{exp:stash:get name='place_id'}$#"
    against="venue_event_venue"
}
    <pre>{venue_event_title}, {venue_event_date}, {venue_event_venue}</pre>
{/exp:stash:get_list}

I can't get {exp:stash:get name='place_id'} to work in the 'match' but on it's own it does return a value.

Grateful for any advice here.

1

Bit late, but anyhow: you need to use parse="inward" when passing a tag as a parameter:

{exp:stash:get_list
    name="venue-events"
    require_prefix="no"
    parse_tags="yes"
    parse_depth="3"
    match="#^{exp:stash:get name='place_id'}$#"
    against="venue_event_venue"
    parse="inward"
}
...
{/exp:stash:get_list}

Alternatively you can use the variable as a placeholder when wrapping with {exp:stash:parse}

{exp:stash:parse}
   {exp:stash:get_list
       name="venue-events"
       require_prefix="no"
       parse_tags="yes"
       parse_depth="3"
       match="#^{stash:place_id}$#"
       against="venue_event_venue"
       parse="inward"
   }
   ...
   {/exp:stash:get_list}

{exp:stash:parse}
| improve this answer | |
0

NOTE: This code is untested!!

Depending on your exact template scenario, try this first:

//Set your stash to wrap the channel entry instead of being contained within
//Use trim to remove whitespace
{exp:stash:set name="place_id" parse_tags="yes" trim="yes"}
{exp:channel:entries
    channel="places"
    status="open"
    {global:channel_disable_basic}
}
{entry_id}
{/exp:channel:entries}
{/exp:stash:set}

If that doesnt work, set the stash as a snippet:

{exp:stash:set name="place_id" parse_tags="yes" trim="yes" type="snippet"}
…
{/exp:stash:set}

Then get it using traditional snippet style:

{exp:stash:get_list
    name="venue-events"
    require_prefix="no"
    parse_tags="yes"
    parse_depth="3"
    match="#^{place_id}$#"
    against="venue_event_venue"
}

I guess if all that fails you can try {exp:stash:parse} something like this:

{exp:stash:parse process="end"}
{exp:stash:get_list
    name="venue-events"
    match="#^{exp:stash:get name='place_id'}$#"
    against="venue_event_venue"
}
    <pre>{venue_event_title}, {venue_event_date}, {venue_event_venue}</pre>
{/exp:stash:get_list}
{/exp:stash:parse}
| improve this answer | |
  • Yeah, sadly nothing gets rendered. :( – doubleplusgood Jul 23 '14 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.