Last active
December 25, 2015 15:09
-
-
Save timkelty/6996339 to your computer and use it in GitHub Desktop.
exp:stash:get_list as parameter value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!-- Load view/model --} | |
{stash:embed:models:page} | |
{exp:low_search:results query="{segment_3}"} | |
{exp:stash:set_value name="total_results" value="{total_results}"} | |
{if no_results} | |
{exp:stash:set_value name="total_results" value="0"} | |
{/if} | |
{exp:switchee | |
variable="{channel_short_name}" | |
parse="inward" | |
} | |
{case value="product"} | |
{exp:stash:append_list name="product"} | |
{stash:embed:models:card | |
stash:channel="product" | |
process="start" | |
} | |
{/exp:stash:append_list} | |
{/case} | |
{case value="resource"} | |
{exp:stash:append_list | |
name="resource" | |
parse_tags="yes" | |
} | |
{stash:title}{title}{/stash:title} | |
{stash:entry_id}{entry_id}{/stash:entry_id} | |
{stash:cat_ids}{categories show_group="2"}{category_id}|{/categories}{/stash:cat_ids} | |
{exp:stash:set_list | |
name="files" | |
context="{entry_id}" | |
} | |
{cf_resource_file} | |
{stash:title}{title}{/stash:title} | |
{stash:extension}{extension}{/stash:extension} | |
{stash:url}{url}{/stash:url} | |
{/cf_resource_file} | |
{/exp:stash:set_list} | |
{/exp:stash:append_list} | |
{/case} | |
{case value="gallery"} | |
{exp:stash:append_list | |
name="gallery" | |
} | |
{stash:html} | |
<a href="{page_uri}"> | |
{exp:ce_img:single | |
src="{cf_gallery_img}" | |
width="133" | |
height="125" | |
crop="yes" | |
fallback_src="/assets/img/placeholder-1000x1000.png" | |
} | |
</a> | |
{/stash:html} | |
{/exp:stash:append_list} | |
{/case} | |
{case value="video"} | |
{exp:stash:append_list | |
name="video" | |
parse_tags="yes" | |
} | |
{stash:embed:models:video process="start"} | |
{/exp:stash:append_list} | |
{/case} | |
{case default="yes"} | |
{exp:stash:append_list name="other"} | |
{stash:title}{title}{/stash:title} | |
{stash:page_uri}{page_uri}{/stash:page_uri} | |
{/exp:stash:append_list} | |
{/case} | |
{/exp:switchee} | |
{/exp:low_search:results} | |
{exp:stash:set_list | |
name="resource_cats" | |
parse_tags="yes" | |
} | |
{!-- entry_id param is not working…can't get the list to parse first --} | |
{exp:gwcode_categories | |
group_id="2" | |
style="linear" | |
show_empty="no" | |
parse="inward" | |
entry_id='{exp:stash:get_list name="resource" backspace="1"}{entry_id}|{/exp:stash:get_list}' | |
} | |
{stash:cat_name}{cat_name}{/stash:cat_name} | |
{stash:cat_id}{cat_id}{/stash:cat_id} | |
{/exp:gwcode_categories} | |
{/exp:stash:set_list} | |
{!-- Page Content --} | |
{exp:stash:page:heading}Search Results for "{exp:low_search:keywords query="{segment_3}"}"{/exp:stash:page:heading} | |
{exp:stash:page:content} | |
{exp:stash:parse process="end"} | |
<div class="Grid Grid--2to1"> | |
<div class="Grid-cell Grid-cell--1"> | |
{if "{exp:stash:total_results}" == "0"} | |
<p>No results found.</p> | |
{/if} | |
{if {exp:stash:not_empty name="product"}} | |
<h2>Products</h2> | |
<div class="Grid Grid--3col"> | |
{exp:stash:get_list name="product"} | |
<div class="Grid-cell"> | |
{stash:embed:partials:card process="start"} | |
</div> | |
{/exp:stash:get_list} | |
</div> | |
{/if} | |
{if {exp:stash:not_empty name="video"}} | |
<h2>Videos</h2> | |
<div class="Grid Grid--3col"> | |
{exp:stash:get_list name="video"} | |
<div class="Grid-cell"> | |
{stash:embed:partials:video | |
process="start" | |
stash:desc="no" | |
} | |
</div> | |
{/exp:stash:get_list} | |
</div> | |
{/if} | |
{if {exp:stash:not_empty name="gallery"}} | |
<h2>Gallery of Ideas & Inspiration</h2> | |
<div class="Grid Grid--4col"> | |
{exp:stash:get_list name="gallery"} | |
<div class="Grid-cell"> | |
<div class="u-marginBm"> | |
{html} | |
</div> | |
</div> | |
{/exp:stash:get_list} | |
</div> | |
{/if} | |
</div> | |
<div class="Grid-cell Grid-cell--2"> | |
{if {exp:stash:not_empty name="resource"}} | |
<h2>Technical Resources</h2> | |
{exp:stash:get_list name="resource_cats"} | |
<h4>{cat_name}</h4> | |
<ul class="NoBullets"> | |
{exp:stash:get_list:resource | |
name="resource" | |
prefix="resource" | |
match="#{cat_id}\|#" | |
against="cat_ids" | |
} | |
{!-- {if resource:count == "1"}<h4>{cat_name}</h4><ul class="NoBullets">{/if} --} | |
<li> | |
{stash:embed:partials:files_by_resource process="start"} | |
</li> | |
{!-- {if resource:count == resource:total_results}</ul>{/if} --} | |
{/exp:stash:get_list:resource} | |
</ul> | |
{/exp:stash:get_list} | |
{exp:stash:get_list | |
name="resource" | |
prefix="resource" | |
match="#^$#" | |
against="cat_ids" | |
} | |
{if resource:count == "1"}<h4>Other</h4><ul class="NoBullets">{/if} | |
<li>{stash:embed:partials:files_by_resource process="start"}</li> | |
{if resource:count == resource:total_results}</ul>{/if} | |
{/exp:stash:get_list} | |
{/if} | |
{if {exp:stash:not_empty name="other"}} | |
<h2>News & Other Content</h2> | |
<ul> | |
{exp:stash:get_list name="other"} | |
<li><a href="{page_uri}">{title}</a></li> | |
{/exp:stash:get_list} | |
</ul> | |
{/if} | |
</div> | |
</div> | |
{/exp:stash:parse} | |
{/exp:stash:page:content} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a very similar problem just a few days ago actually when attempting to use
search:field="{exp:stash:piped-ids}"
.I tried loads of different things trying to get it to work. In the end I moved my two sections into separate stash embeds with
process="start"
and shifted them to the top of the template to ensure the first one gets parsed before the second. (In your case the two chunks to be moved into embeds would be 1: your whole low_search:results tag, and 2: line 81-96.)I also built the piped list directly with a simple
append
tag, then fetched it in the second embed with a simpleentry_id="dummy-{stash:piped-ids}"
to avoid the backspace inconvenience.Make sense? In your case it may be worth just building a plugin, since this template is arguably getting more complicated than a chunk of php arrays...!
These are my two Stash embeds:
1: https://gist.github.com/thisisjamessmith/18d85e978b714aaf2eef
2: https://gist.github.com/thisisjamessmith/6a1b4446d2097958939c
Then in the main template: