We are building a fairly large & complex site. The problem I am running into is one of limiting. Here's what I need it to do:
There are various sectors. Each sector has a landing page. On the landing pages we display news stories relating to that particular sector. The way we do this is to use Playa in the news story entry to select the related sector(s), and then pull through the entries on the sector landing page templates like this:
{exp:channel:entries channel="news-article" dynamic="off" orderby="date" sort="desc"}
{exp:playa:children var_prefix="news" field="news-related-sector"}
{if {structure:page:entry_id} == {news:entry_id}}
<article class="aside-news-listing">
<a href="{page_url}">
{if news-thumbnail}
<img src="{news-thumbnail:news-thumbnail}" alt="{title}" />
{if:elseif news-image}
<img src="{news-image:news-thumbnail}" alt="{title}" />
{/if}
</a>
<div class="article-text-block">
<h3><a href="{page_url}">{title}</a></h3>
<ul>
{categories}
<a href="{path='news/'}"><li class="sector1text">{category_name}</li></a>
{/categories}
</ul>
<span>{entry_date format='%d %F %Y'}</span>
</div>
</article>
{/if}
{/exp:playa:children}
{/exp:channel:entries}
Now this works fine - but it pulls through all news entries related to that sector, and we only want to display the latest 2.
I have tried using limit="2" on the channel entries tag and nothing displays. I'm guessing this is because it just selects the first 2 entries and never hits one that is related to the sector.
I have also tried using limit="2" on the playa children tag but all related news stories display - not limited.
I have tried using an {if count <= 2} conditiona inside and outside of the playa tag and inside the entry_id conditional and nothing is displayed in any case. I'm now out of ideas! Can anyone shed some light on this?
Thanks!
Notes: I am using EE 2.6.1 and Playa 4.4.5. I know this might not be the best way to achieve what we want to - but I didn't build it and it's what I have to work with :-P