2

I have a xml template with an embedded stash xml partial. But I'm not getting any output.

This is my xml:

{stash:embed:viewmodels:categories process="inline" stash:entry_id="{entry_id}"}
    <category_sport_name_ms>
    {exp:stash:get_list name="export_categories" match="#sport#" against="type"}
    <str><![CDATA[{name}]]></str>
    {/exp:stash:get_list}
    </category_sport_name_ms>

And this is my viewmodel categories.xml (also tried html)

{exp:stash:set_list name="export_categories" parse_tags="yes"}
{exp:gwcode_categories group_id="2" entry_id="{stash:entry_id}" style="linear"}
    {stash:type}sport{/stash:type}
    {stash:name}{cat_name}{/stash:name}
    {stash:id}{cat_id}{/stash}
    {stash:color}{cat_description}{/stash:color}
    {stash:url}{cat_url_title}{/stash:url}
{/exp:gwcode_categories}
{exp:gwcode_categories group_id="1" entry_id="{stash:entry_id}" style="linear"}
    {stash:type}age{/stash:type}
    {stash:name}{cat_name}{/stash:name}
    {stash:id}{cat_id}{/stash:id}
    {stash:url}{cat_url_title}{/stash:url}
{/exp:gwcode_categories}
{exp:gwcode_categories group_id="3" entry_id="{stash:entry_id}" style="linear"}
    {stash:type}theme{/stash:type}
    {stash:name}{cat_name}{/stash:name}
    {stash:id}{cat_id}{/stash:id}
    {stash:url}{cat_url_title}{/stash:url}
{/exp:gwcode_categories}

{/exp:stash:set_list}

Even if I remove the set list and just enter something like test there is still no output? Is xml unsupported? Thanks!

3

You're essentially using the embed as a snippet, so you could do this:

{!-- viewmodels/categories.html - include the code but don't parse --}
{stash:embed:viewmodels:categories process="start" parse="no"}
<category_sport_name_ms>
{exp:stash:get_list name="export_categories" match="#^sport$#" against="type"}
<str><![CDATA[{name}]]></str>
{/exp:stash:get_list}
</category_sport_name_ms>

In viewmodels/categories.html, just use {entry_id} instead of {stash:entry_id}.

You also need to ensure that your list columns are consistent for every row. That means you must use the same column names for each of your three uses of gwcode_categories:

{stash:type}sport{/stash:type}
{stash:name}{cat_name}{/stash:name}
{stash:id}{cat_id}{/stash}
{stash:color}{cat_description}{/stash:color}
{stash:url}{cat_url_title}{/stash:url}

(Leave the value empty if it doesn't exist)

| improve this answer | |
  • Hi Mark, I thought this would work, but actually it isn't. All of this happens in a channel entries loop. I just can't get results. Hmmm. Maybe you know what's going on? I also tried process inline, but that doesn't work too. – Dion Snoeijen Feb 12 '14 at 16:23

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.