0

We seem to be having some problems limiting within an embed.

2 Channels: Daily-Deals (approx 50 listings), Business-Listing (approx 10,000 listings).

Each daily deal is related to a single business on field: "deal-owner".

Each business is categorized in a "zone" (category URL corresponds to the template group URL). ie: business is categorized to the zone "Rapid City" (category URL is "rapid-city")

The template structure is as follows: www.website.com/rapid-city/restaurants

Step 1 - Identify all the daily deals that have content in the field "monday-deal". Pass these business ids to the embed. (Identifies 26 records)

{exp:channel:entries channel="daily-deals" search:monday-deal="not IS_EMPTY"}
{embed="rapid-city/deal-embed" deals="{deal-owner status="Super Enhanced|Enhanced|Basic"}{entry_id}{/deal-owner}"}
{/exp:channel:entries}

Step 2 - In this embed, take the passed ids and filter to identify only those businesses that have the matching category as the segment_1 category id (in this case when viewing the rapid-city/restaurants template, it would only show the deals from the businesses that are categorized as "Rapid City") (filters down to 21 records)

Step 3 - Then display the deal information (from daily-deal) and the business title, city and state (from business listing).

{exp:channel:entries entry_id="{embed:deals}" channel="business-listing" category="{segment_1_category_id}" status="Super Enhanced|Enhanced|Basic"}
{exp:playa:parents channel="daily-deals"}{monday-deal}{/exp:playa:parents} - {title} - {city},{state-short}<br>
{/exp:channel:entries}

Using this code, in step 1, it correctly identifies the 26 records that have "monday-deal" content.

In Step 2 it filters the 26 records and returns only the 21 that have a matching category selection (business category URL matches rapid-city from segment_1)

In step 3, it correctly displays the monday-deal for each of the 21 businesses and the business title, city and state.

BUT, we want to limit the output display within the template to 6 entries!

IF we put limit="6" in the outer template (or use other conditional strategies), it only passes 6 ids (of the possible 26) to the embed. Thus when the embed processes the records, it may be removing some of the 5 that should not be there - resulting in the display of a random number of entries from 1-6.

{exp:channel:entries channel="daily-deals" search:monday-deal="not IS_EMPTY" limit="6"}
{embed="rapid-city/deal-embed" deals="{deal-owner status="Super Enhanced|Enhanced|Basic"}{entry_id}{/deal-owner}"}
{/exp:channel:entries}

IF we put limit="6" within the code of the embed - it does nothing (all 21 records are displayed!)

{exp:channel:entries entry_id="{embed:deals}" channel="business-listing" category="{segment_1_category_id}" status="Super Enhanced|Enhanced|Basic" limit="6"}
{exp:playa:parents channel="daily-deals"}{monday-deal}{/exp:playa:parents} - {title} - {city},{state-short}<br>
{/exp:channel:entries}

HOW can we use this process to identify all the records that meet the criteria - and always display only 6 records of the 21 possible?

0
1

Using a count conditional should do the trick if I'm understanding the issue.

21 records will still be returned but only 6 will "show". This is not ideal because your tag is doing more work than it needs to do. Also, there might be performance issues if tons of entry_ids are passed to {embed:deals}.

{exp:channel:entries entry_id="{embed:deals}" channel="business-listing" category="{segment_1_category_id}" status="Super Enhanced|Enhanced|Basic" limit="6"}
{if count < 7}
        {exp:playa:parents channel="daily-deals"}{monday-deal}{/exp:playa:parents} - {title} - {city},{state-short}<br>
{/if}
{/exp:channel:entries}
2
  • Putting this in the code doesn't change the results. Still displays 21 records. – DigitalDesigns Apr 25 '13 at 20:09
  • Have you tried {exp:playa:parents channel="daily-deals" limit="6"}? – Anna_MediaGirl Apr 29 '13 at 3:41
0

The limit in the embed is of no use, since for every entry_id found in the template it will embed the other template.

to pass all entry id's at once to the embed

{embed="test/embed_test" all="{exp:channel:entries channel='test_channel' backspace='1'}{entry_id}|{/exp:channel:entries}"}
// {embed:all} contains 12|22|44
5
  • So how can we control the number of entries displayed in the template? Of the 21 records that match the criteria, how can we ensure 6 are shown? – DigitalDesigns Apr 23 '13 at 16:22
  • editted the answer. However i think you could start with the business-listing channel with category and then search the parent channel for monday-deals, maybe no need for an embed. – GDmac Apr 23 '13 at 16:30
  • We run into the issue either way (limiting to 6 entries). Our OBJECTIVE is to show 6 entries from the daily-deal channel that have content in the monday-deal text field AND whose deal-owner is categorized the same as the zone we are viewing (category URL matches page URL). – DigitalDesigns Apr 23 '13 at 18:03
  • i would have to dive in to see how and what, and that is beyond the scope of this stackexchange. i'm pretty sure this can be optimized and figured out. – GDmac Apr 23 '13 at 19:45
  • since I can get it down to the 21 records, any thoughts on using Stash to reduce to 6 records? – DigitalDesigns Apr 23 '13 at 22:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.