Skip to main content
added 4 characters in body
Source Link

EDIT: Mark "The" Croxton was quick again: Stash 2.4.4 has been updated to ignore empty list itemsEDIT: Mark "The" Croxton was quick again: Stash 2.4.4 has been updated to ignore empty list items which apparently was the problem here.

EDIT: Mark "The" Croxton was quick again: Stash 2.4.4 has been updated to ignore empty list items.

EDIT: Mark "The" Croxton was quick again: Stash 2.4.4 has been updated to ignore empty list items which apparently was the problem here.

deleted 2731 characters in body
Source Link

EDIT: Getting a lot closer

Updated EDIT: Mark "The" Croxton was quick again: Stash to 2.4.3. and refactored using just append_list and adding another parameter to be able to sort the lit when I get it. Works great but I cannot for the life of me work out how4 has been updated to do multiple orderby and sort hereignore empty list items.

{!-- Extended page template --}
{stash:embed name="layouts:page"}

{!-- SET Entry data --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles" status="not closed" require_entry="yes" limit="1"}

    {!-- Get first 4 related items in Playa field (combined with latest article and interviews if less than 4 --}
    {exp:playa:children channel="articles|interviews" limit="4"}

        {exp:stash:append_list name="st_complementary_items"}
            {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
            {stash:st_complementaryitem_type}playa{/stash:st_complementaryitem_type}
            {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
            {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
        {/exp:stash:append_list}

    {/exp:playa:children}

{/exp:channel:entries}

{!-- Get last 4 published articles / interviews items (completes the list if less than 4 in the Playa field  --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles|interviews" status="not closed" orderby="date" sort="desc" dynamic="no" limit="4"}

    {exp:stash:append_list name="st_complementary_items"}
        {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
        {stash:st_complementaryitem_type}recent{/stash:st_complementaryitem_type}
        {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
        {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
    {/exp:stash:append_list}

{/exp:channel:entries}

{!-- BUILD page content --}
{exp:stash:set name="content"}

        <p>Total items in list: {exp:stash:list_count name="st_complementary_items"}</p>
        <p>Unique items in list: {exp:stash:list_count name="st_complementary_items" unique="st_complementaryitem_title"}</p>

        {!-- get the list of related items (Playa + recent), order by playa first, order entries inside each group by date (@TODO make it unique on the title, which works) --}
        {exp:stash:get_list name="st_complementary_items" orderby="st_complementaryitem_type|st_complementaryitem_date_machine" sort="asc|desc"}
            <p>[{count}/{total_results}] - {st_complementaryitem_title} - {st_complementaryitem_date} - {st_complementaryitem_type}</p>
        {/exp:stash:get_list}

{/exp:stash:set}

EDIT: Getting a lot closer

Updated Stash to 2.4.3. and refactored using just append_list and adding another parameter to be able to sort the lit when I get it. Works great but I cannot for the life of me work out how to do multiple orderby and sort here.

{!-- Extended page template --}
{stash:embed name="layouts:page"}

{!-- SET Entry data --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles" status="not closed" require_entry="yes" limit="1"}

    {!-- Get first 4 related items in Playa field (combined with latest article and interviews if less than 4 --}
    {exp:playa:children channel="articles|interviews" limit="4"}

        {exp:stash:append_list name="st_complementary_items"}
            {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
            {stash:st_complementaryitem_type}playa{/stash:st_complementaryitem_type}
            {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
            {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
        {/exp:stash:append_list}

    {/exp:playa:children}

{/exp:channel:entries}

{!-- Get last 4 published articles / interviews items (completes the list if less than 4 in the Playa field  --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles|interviews" status="not closed" orderby="date" sort="desc" dynamic="no" limit="4"}

    {exp:stash:append_list name="st_complementary_items"}
        {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
        {stash:st_complementaryitem_type}recent{/stash:st_complementaryitem_type}
        {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
        {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
    {/exp:stash:append_list}

{/exp:channel:entries}

{!-- BUILD page content --}
{exp:stash:set name="content"}

        <p>Total items in list: {exp:stash:list_count name="st_complementary_items"}</p>
        <p>Unique items in list: {exp:stash:list_count name="st_complementary_items" unique="st_complementaryitem_title"}</p>

        {!-- get the list of related items (Playa + recent), order by playa first, order entries inside each group by date (@TODO make it unique on the title, which works) --}
        {exp:stash:get_list name="st_complementary_items" orderby="st_complementaryitem_type|st_complementaryitem_date_machine" sort="asc|desc"}
            <p>[{count}/{total_results}] - {st_complementaryitem_title} - {st_complementaryitem_date} - {st_complementaryitem_type}</p>
        {/exp:stash:get_list}

{/exp:stash:set}

EDIT: Mark "The" Croxton was quick again: Stash 2.4.4 has been updated to ignore empty list items.

added 2904 characters in body
Source Link

EDIT: Getting a lot closer

Updated Stash to 2.4.3. and refactored using just append_list and adding another parameter to be able to sort the lit when I get it. Works great but I cannot for the life of me work out how to do multiple orderby and sort here.

{!-- Extended page template --}
{stash:embed name="layouts:page"}

{!-- SET Entry data --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles" status="not closed" require_entry="yes" limit="1"}

    {!-- Get first 4 related items in Playa field (combined with latest article and interviews if less than 4 --}
    {exp:playa:children channel="articles|interviews" limit="4"}

        {exp:stash:append_list name="st_complementary_items"}
            {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
            {stash:st_complementaryitem_type}playa{/stash:st_complementaryitem_type}
            {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
            {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
        {/exp:stash:append_list}

    {/exp:playa:children}

{/exp:channel:entries}

{!-- Get last 4 published articles / interviews items (completes the list if less than 4 in the Playa field  --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles|interviews" status="not closed" orderby="date" sort="desc" dynamic="no" limit="4"}

    {exp:stash:append_list name="st_complementary_items"}
        {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
        {stash:st_complementaryitem_type}recent{/stash:st_complementaryitem_type}
        {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
        {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
    {/exp:stash:append_list}

{/exp:channel:entries}

{!-- BUILD page content --}
{exp:stash:set name="content"}

        <p>Total items in list: {exp:stash:list_count name="st_complementary_items"}</p>
        <p>Unique items in list: {exp:stash:list_count name="st_complementary_items" unique="st_complementaryitem_title"}</p>

        {!-- get the list of related items (Playa + recent), order by playa first, order entries inside each group by date (@TODO make it unique on the title, which works) --}
        {exp:stash:get_list name="st_complementary_items" orderby="st_complementaryitem_type|st_complementaryitem_date_machine" sort="asc|desc"}
            <p>[{count}/{total_results}] - {st_complementaryitem_title} - {st_complementaryitem_date} - {st_complementaryitem_type}</p>
        {/exp:stash:get_list}

{/exp:stash:set}

EDIT: Getting a lot closer

Updated Stash to 2.4.3. and refactored using just append_list and adding another parameter to be able to sort the lit when I get it. Works great but I cannot for the life of me work out how to do multiple orderby and sort here.

{!-- Extended page template --}
{stash:embed name="layouts:page"}

{!-- SET Entry data --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles" status="not closed" require_entry="yes" limit="1"}

    {!-- Get first 4 related items in Playa field (combined with latest article and interviews if less than 4 --}
    {exp:playa:children channel="articles|interviews" limit="4"}

        {exp:stash:append_list name="st_complementary_items"}
            {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
            {stash:st_complementaryitem_type}playa{/stash:st_complementaryitem_type}
            {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
            {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
        {/exp:stash:append_list}

    {/exp:playa:children}

{/exp:channel:entries}

{!-- Get last 4 published articles / interviews items (completes the list if less than 4 in the Playa field  --}
{exp:channel:entries disable="member_data|pagination|trackbacks" channel="articles|interviews" status="not closed" orderby="date" sort="desc" dynamic="no" limit="4"}

    {exp:stash:append_list name="st_complementary_items"}
        {stash:st_complementaryitem_title}{title}{/stash:st_complementaryitem_title}
        {stash:st_complementaryitem_type}recent{/stash:st_complementaryitem_type}
        {stash:st_complementaryitem_date}{entry_date format="%F %d, %Y"}{/stash:st_complementaryitem_date}
        {stash:st_complementaryitem_date_machine}{entry_date format="%Y-%m-%d"}{/stash:st_complementaryitem_date_machine}
    {/exp:stash:append_list}

{/exp:channel:entries}

{!-- BUILD page content --}
{exp:stash:set name="content"}

        <p>Total items in list: {exp:stash:list_count name="st_complementary_items"}</p>
        <p>Unique items in list: {exp:stash:list_count name="st_complementary_items" unique="st_complementaryitem_title"}</p>

        {!-- get the list of related items (Playa + recent), order by playa first, order entries inside each group by date (@TODO make it unique on the title, which works) --}
        {exp:stash:get_list name="st_complementary_items" orderby="st_complementaryitem_type|st_complementaryitem_date_machine" sort="asc|desc"}
            <p>[{count}/{total_results}] - {st_complementaryitem_title} - {st_complementaryitem_date} - {st_complementaryitem_type}</p>
        {/exp:stash:get_list}

{/exp:stash:set}
Source Link
Loading