We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Entries long page load

How Do I?

hellodaylight's avatar
hellodaylight
26 posts
about 11 years ago
hellodaylight's avatar hellodaylight

I’ve really been struggling with load times for a specific page on my site. Currently the load time is average about 30 seconds, with hundreds of queries. The page isn’t anything super special, just a listing of entries.

Members submit a form, adding an entry into the Applications channel, and I’ve created a page for admin members to login and view a list of the submitted applications. The applications have a relationship field linking them to a specific Event (Show). So to list the applications for a specific show to admins, I use a reverse relationship. There are also some conditionals within the list that show different things to different member groups (admin / juror). I also have the Channel Images field on the application, which retrieves the first of five images per entry and displays it as a thumbnail (the image is small - 80px X 80px).

I’ve tried everything to reduce the advanced conditionals (if/else, switchee), and optimize code, to no avail. I can shave off a couple seconds at best.

It seems like just listing a couple hundred entries in a table shouldn’t be very taxing. I’m at my wits end. Does anyone have any ideas how I can optimize the following code?

{exp:channel:entries channel="shows" dynamic="yes" url_title="{segment_3}" show_future_entries="yes" disable="categories|pagination"}
 {parents channel="applications" field="show" orderby="date" {embed:filter}}
  {if parents:no_results}
   <tr>
    <td align="center" colspan="100%" class="padding-top-30 padding-bottom-30">
     No applications found.
    </td>
   </tr>
  {/if}

  <tr>
   {if logged_in_group_id == '1' || logged_in_group_id == '7'}<td><input name="id[]" class="checkbox" type="checkbox" value="{parents:entry_id}" /></td>{/if}
   
   <td data-value="{parents:entry_date format='%U'}">
    <small>{parents:entry_date format="%d %M '%y"}</small>
   </td>
   
   <td>
       {parents:images limit="1"}
        {image:url:small}
       {/parents:images}   
   </td>
   
   <td>{if logged_in_group_id == '1' || logged_in_group_id == '7'}<a href="http://{path=%27admin/crafter%27}/{parents:author_id}" title="View Crafter Profile" class="tip">{/if}{parents:author} <span class="hidden">{parents:email}</span>{if logged_in_group_id == '1' || logged_in_group_id == '7'}</a>{/if}</td>
   
   <td>
    {parents:cat}
     {parents:cat:title} <span class="hidden">category-{parents:cat:entry_id}-category</span>
    {/parents:cat}
   </td>
   
   {if logged_in_group_id == '1' OR logged_in_group_id == '6' OR logged_in_group_id == '7'}
   <td class="text-center">
    {parents:space_size} <span class="hidden">{parents:space_size}-space</span>
   </td>
   
   <td class="text-center">
    {parents:table_size} <span class="hidden">{parents:table_size}-table</span>
   </td>
   {/if}
   
   <td class="text-center">
    {if '{parents:fresh_catch}' == 'Yes'}
     <i class="fa fa-check text-success"></i> <span class="hidden">fresh-catch-yes</span>
    {if:else}
     <i class="fa fa-times text-danger"></i> <span class="hidden">fresh-catch-no</span>
    {/if}
   </td>
   
   {if logged_in_group_id == '1' || logged_in_group_id == '7'}
   <td class="text-center">
    {if '{parents:fee}' == 'Paid'}
     <i class="fa fa-check text-success"></i> <span class="hidden">fee-paid</span>
    {/if}
    {if '{parents:fee}' == 'Deposit'}
     <i class="fa fa-ellipsis-h text-warning"></i> <span class="hidden">fee-deposit</span>
    {/if}
    {if '{parents:fee}' == 'Unpaid'}
     <i class="fa fa-times text-danger"></i> <span class="hidden">fee-unpaid</span>
    {/if}
   </td>
   {/if}
   
   {if logged_in_group_id == '1' || logged_in_group_id == '7'}
   <td class="text-center">
    {if '{parents:status}' == 'pending'}
     <i class="fa fa-ellipsis-h text-warning"></i> <span class="hidden">status-pending</span>
    {/if}
    {if '{parents:status}' == 'accepted'}
     <i class="fa fa-check text-success"></i> <span class="hidden">status-accepted</span>
    {/if}
    {if '{parents:status}' == 'rejected'}
     <i class="fa fa-times text-danger"></i> <span class="hidden">status-rejected</span>
    {/if}
   </td>
   {/if}
   
   <td class="actions text-right">
    <a href="http://{parents:permalink=%27admin/application-modal%27}%22class=%22btn" title="View" class="btn btn-primary" target="#myModal" rel="noopener"><i class="fa fa-eye"></i></a>
    {if logged_in_group_id == '1' || logged_in_group_id == '7'}
     <a href="http://{parents:permalink=%27admin/application%27}/{segment_3}%22class=%22btn" title="Edit" class="btn btn-primary margin-right-15"><i class="fa fa-pencil-square-o"></i></a>
    {/if}
   </td>
  </tr>
 {/parents}
 
 {if no_results}
  <tr>
   <td colspan="100%" align="center" class="padding-top-30 padding-bottom-30">
    No applications found.
   </td>
  </tr>
 {/if}
{/exp:channel:entries}
       
Boyink!'s avatar
Boyink!
5,011 posts
about 11 years ago
Boyink!'s avatar Boyink!

Where is the site hosted?

       
hellodaylight's avatar
hellodaylight
26 posts
10 years ago
hellodaylight's avatar hellodaylight

The site is hosted on MediaTemple Gridserver. I tried it on a MT DV, but it wasn’t much better. However I was able to cut the page load from 30 seconds down to 4 seconds. I did this by removing all of the conditionals in the listing portion of the code that looks at the logged in member group is and shows and hides elements for different groups, and instead creating different versions of the list for those member groups, and just using one conditional to show the needed version. It duplicates code for the different versions of the list, which isn’t ideal, but it works much better now. I can’t believe how much processing power the conditionals use. Thanks

       
sheferd's avatar
sheferd
31 posts
10 years ago
sheferd's avatar sheferd

A good solution I found for having large amounts of conditionals is to use a plugin called switchee, might be worth a look…

https://devot-ee.com/add-ons/switchee

if you’re up for getting really technical and advanced this combined with Stash: https://devot-ee.com/add-ons/stash

Can shave a lot of time off page loads.

Good luck

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.