0

I am working on a site that has an employees channel with over 1000 entries. When a user visits the "all employees" page we are paginating the results and all is well, however when a user views the print template for this page the client would like the full list of employees to be shown. When this template is loaded the request times out.

I have optimised the template as best I can (simple conditionals, etc) and tried upping the PHP execution time, but still no luck. I think the biggest killer to rendering is that we need to access a matrix and a playa field for each employee. If anyone has any advice on ways to get this page to load that would be greatly appreciated.

EDIT: Updated with code sample

{exp:channel:entries
    site="default_site"
    channel="employees"
    orderby="title" sort="asc"
    disable="categories|category_fields|member_data|pagination"
    limit="10000"
    entry_id="{alpha_ids}"
    cache="yes" refresh="720"
}
<tr>
    <td>{title}</td>
    <td>{p_position}</td>
    <td>{p_locations limit="1"}{office site="default_site"}{title}{/office}{/p_locations}</td>
    <td>{if p_locations}{p_locations limit="1"}{phone}{/p_locations}{/if}{if p_locations == ""}{p_phone}{/if}</td>
    <td>{p_email_address}</td>
</tr>
{/exp:channel:entries}

In this code snippet {alpha_ids} is the result of filters (in the case causing the issue, this contains all entries). {p_locations} is a matrix field. The columns in this matrix are {office} (playa single-select) and {phone} (text field).

3
  • Sure. If you're using Matrix and Playa then those modules provide looping tag pairs which will each loop with the outer EE channel entries loop so it could very well be a more efficient way of doing things. You'll need to post your retrieval code for us to see what the bottleneck could be though.
    – Ian Young
    May 9, 2013 at 12:14
  • So {alpha_ids} is a snippet? If you're loading all entries from the channel then you don't need to specify the entry IDs individually like that unless you're only including certain entries.
    – Ian Young
    May 9, 2013 at 20:26
  • Have you tried limiting to just a 100 or so to see if it works on fewer entries? Then you could gradually increase to see if and when it stops working to find the break point. Just to ensure that it's a timeout/performance issue.
    – Ian Young
    May 9, 2013 at 20:53

3 Answers 3

1

That's a lot of entries to load for sure. I've done something like this once before with map data, but the solution may be the same for you. Assuming that your template is as optimized as it's going to get, you may need to cache and retrieve the "all" list in chunks - that's what I had to do for my map data. I did it using Solspace Template Morsels. It allowed me to chunk up my list into manageable groups (distinct entries loops with start and end points), cache them (a bunch of options for how long to cache and under what conditions to break the cache), and then assemble them into the single template. On top of that, you could cache the "assembled" template as well.

2
  • I don't have experience with Solspace's Template Morsels, do you have any code examples on doing something like this. I have also updated my question to include the code that is being used in the template. May 9, 2013 at 13:04
  • It would be a pretty long thing to include. Basically it works like this - in the control panel within the template morsels settings panel, you would create each "morsel". So your first one might be the exact same entries loop but with a limit of 100. Your second one might be the same, again with a limit of 100 but with an offset of 100 (meaning the second loop starts at 101). And so on - chunking it into blocks of 100, for example. Then in the template, instead of your entries loop, you just reference the morsels (with the module's own tags) and voila. May 9, 2013 at 13:32
0

Thanks for your help, there are some excellent resources to consider when I have the time to dig in and figure them out.

In the end I got a solution similar to this working. Here is the code I have working now:

{exp:channel:entries
    site="default_site"
    channel="employees"
    orderby="title" sort="asc"
    disable="categories|category_fields|member_data|pagination"
    limit="10000"
    entry_id="{alpha_ids}"
    cache="yes" refresh="720"
}
<tr>
    <td>{title}</td>
    <td>{p_position}</td>
    <td>
        {exp:playa:children
            site="default_site"
            field="p_locations"
            col="office"
            limit="1"
            disable="custom_fields|categories|category_fields|member_data|pagination"
        }
            {title}
        {/exp:playa:children}
    </td>
    <td>
        {if p_locations}{p_locations limit="1"}{phone}{/p_locations}{/if}
        {if p_locations == ""}{p_phone}{/if}
    </td>
    <td>{p_email_address}</td>
</tr>
{/exp:channel:entries}

Basically, the change just reduces a call to Matrix and skips straight to pulling the Playa data.

0
0

Try CE Cache http://devot-ee.com/add-ons/ce-cache. Very easy to implement. I had a matrix/playa "problem" and CE Cache sped up the page incredibly.

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.