1

I am running the latest version of Expression Engine (2.6.1) and Matrix (2.5.5).

I created a Matrix field for an Award Winners listing for our website, with 2 fields - the first being Field Pack - Dropdown (for award years) and second being plain text (winner's name). In my actual code, I am pulling out the award winners in a list by year like so:

    {if award_list!=""}

        {award_list sort="desc" limit="150"}

            {if award_year=="{prev_row}{award_year}{/prev_row}"}

            {if:elseif award_year=="{next_row}{award_year}{/next_row}"}

            {if row_index!="0"}<br />{/if}<br /><strong>{award_year}&nbsp;&nbsp;</strong>

            {if:else}

            {if row_index!="0"}<br />{/if}<br /><strong>{award_year}&nbsp;&nbsp;</strong>

            {/if}

            {if award_year!="{next_row}{award_year}{/next_row}"}{award_winner}{if:else}{award_winner}, {/if} 

        {/award_list}

    {/if}

This does run successfully, but locks up when looking for the Matrix channel_entries_tagdata. This what the template debugging says:

(0.084529 / 5.51MB)       -> Class Called: Channel 
(0.087144 / 5.65MB)       -> Method Called: entries
(0.139607 / 8.05MB)      Calling Extension Class/Method: Assets_ext/channel_entries_query_result
(0.177234 / 9.17MB)      Calling Extension Class/Method: Playa_ext/channel_entries_tagdata
(0.179309 / 9.20MB)      Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata
(4.989313 / 9.99MB)       -> Data Returned
(4.989540 / 9.98MB)       - End Tag Processing -
(4.989713 / 9.98MB)      Processing Advanced Conditionals
(5.837677 / 10.04MB)      Processing Sub Template: includes/footer

I wasn't sure if there was an issue with my if statement, or there is another issue going on with the fieldtype. Any help would be great.

0

How many database queries is your template code generating? If you're not sure, turn on EE's Output Profiler. Admin > System Administration > Output and Debugging.

Every time you use the {prev_row} and {next_row} tags you will be adding an additional database query to your page. This will be compounded as you are using the tags within your matrix loop. So if you're displaying 150 matrix rows you'd be looking at about 450 queries just to display this section of your template.

You could try using PHP in your template, set to input, to save and compare the previous row values instead of using the {prev_row} tag. This obviously doesn't work for the {next_row} tag but based on your example I don't think you'd need to do this anyway. If you need help grouping the matrix rows under a year heading it might be best to post another question dealing directly with that issue.

1
  • I turned on Output and Debugging, and found out that the code was generating over 1,500 queries. Definitely not very efficient! I'm going to rework the code - thanks for the help. – Jon Shearer Jun 10 '13 at 18:55
0

the system you've built there seems like it could be a pretty big drain on the system - can you try removing all the if statements to see how quick everything loads? If there's a significant difference, then you might want to think up on a cleaner approach that might save you time.

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.