I need to merge to loops into one stash list.
The first loop is a standard channel entries loop. The second is a twitter time line, using CE Twitter.(http://www.causingeffect.com/software/expressionengine/ce-tweet)
Here is my code thus far, I've removed a lot of the markup and variables et al...
{!-- set list --}
{exp:stash:set_list name='journal_list' parse_tags='yes' depth="2" parse="inward"}
{exp:channel:entries channel="journal" dynamic="no" paginate="bottom" sort="desc" limit="10"}
{!-- append to the list the channel entries --}
{exp:stash:append_list name='journal_list' parse_tags='yes' depth="2" parse="inward"}
{!--type set as post, used to output post markup --}
{stash:type}post{/stash:type}
{!-- entry date saved to variable - the idea is to then use this as the order by argument --}
{stash:entry_date}{entry_date}{/stash:entry_date}
{!-- All the usual gubbins, titles, images, text et all, all sorted in stash variables --}
{/exp:stash:append_list}
{/exp:channel:entries}
{exp:ce_tweet:user_timeline screen_name="myMegaTwitterAccount" count="5" sort="asc"}
{!-- append to the same list as above for the twitter time line --}
{exp:stash:append_list name='journal_list' parse_tags='yes' depth="2" parse="inward"}
{!--type set as tweet, used to output tweet markup --}
{stash:type}tweet{/stash:type}
{!-- entry date saved to variable - the idea is to then use this as the order by argument --}
{stash:entry_date}{created_at}{/stash:entry_date}
{/exp:stash:append_list}
{/exp:ce_tweet:user_timeline}
{/exp:stash:set_list}
{exp:stash:get_list name='journal_list' order_by="{entry_date}" paginate="bottom" limit="5"}
{if "{type}" == "Post"}
{!-- all the post markup here --}
{if:else}
{!-- all the tweet markup here --}
{/if}
{/exp:stash:get_list}
The code above works, but not quite right.
Currently the two lists are outputted separately, i.e. first all of the channel entries are outputted, then all the tweets.
What I need is for the sort order to be based solely on the {entry_date}, so the tweets and posts will be mixed up... [post post tweet post tweet post post] etc etc
I'm sure this will be possible, I may have approached this incorrectly. Fairly new to stash, although I have to say I'm bloomin' loving it (Thanks Mark!)
I've added a screenshot below which should illustrate the issue I have, notice the dates on the items. eeee! (n.b using masonry for the layout)
Any help, greatly appreciated
{stash:entry_date}
- your approach relies upon these being similarly scaled numbers, but if this assumption is not true (silly example, but if each was using a different year for the date) it would explain why they are being output in the order you see. Might be worth doing a quick test that just lists out the title and date (in order) to see if dates are indeed of the same type...