Fatal error with pagelist on multiple columns (FIXED)
Permalink
I have the following code in a pagelist template
The pages display correctly until the last one where I get a fatal error message,
this occurs immediately after the last link in the list, like it is looking for more pages in the array?
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $textHelper = Loader::helper("text"); // now that we're in the specialized content file for this block type, // we'll include this block type's class, and pass the block to it, and get // the content ?> <style type="text/css"> .colmask {clear:both; float:left; width:100%; overflow:hidden }/* common column settings */ .colleft {float:left;width:100%; }/* 2 Column (double page) settings */ .doublepage img{ width:200px; height:120px; margin-bottom: 20px } .doublepage .colleft {/*right:50%; right column width */} .doublepage .col1, .doublepage .col2, .doublepage .col3, .doublepage .col4 { width:24%; float:left} .doublepage .col1 {padding:5px 0 5px 25px} .doublepage .col2 {padding:5px 5px 5px 0}
Viewing 15 lines of 90 lines. View entire code block.
The pages display correctly until the last one where I get a fatal error message,
Fatal error: Call to a member function getCollectionName() on a non-object in F:\wamp\www\blocks\page_list\templates\four_columns.php on line 30
this occurs immediately after the last link in the list, like it is looking for more pages in the array?
I copied your code into a page_list block template and it worked with no errors. Did you try clearing site cache?
Yes, Cleared the cache.. Same result?
Perhaps it is my Wamp setup?
Perhaps it is my Wamp setup?
Does the default page_list block work?
Yes, Perfectly..
Ok so I noticed it might have something to do with the page_list criteria. When I have selected the everywhere option or beneath this page, there are no errors. But I get the error you did when selecting beneath another page. Curious...
Ha Ha, I am not going mad then,
I just tested this on a "live" site with the same error, so that rules out my Wamp install..
I just tested this on a "live" site with the same error, so that rules out my Wamp install..
Every test I have done fails with the same fatal error message immediately after the last item in the array has loaded?
I suspect the error is further back in the system, returning a list with null items in it or at least at the end.
Some ideas to patch it in the view:
- do an array_filter()on the list to remove null items
- do an is_object() test of $cobj and 'continue' or 'break' if it is not an object.
Totally aside from the issue, on the column membership tests, you could get away using <16 for all of them, or even use a nested loop with the outer loop running through foreach of the column styles, then using the outer loop index as the starting offset for the inner loop.
Some ideas to patch it in the view:
- do an array_filter()on the list to remove null items
- do an is_object() test of $cobj and 'continue' or 'break' if it is not an object.
Totally aside from the issue, on the column membership tests, you could get away using <16 for all of them, or even use a nested loop with the outer loop running through foreach of the column styles, then using the outer loop index as the starting offset for the inner loop.
Thanks John,
Thats given me some ideas to run with although some of it went right over my head..
A little research is in order me thinks..
Thats given me some ideas to run with although some of it went right over my head..
A little research is in order me thinks..
I fixed this problem by changing this
For this
for ($i = 1; $i < 16; $i+=4 )
For this
for ($i = 1; $i < count($cArray); $i+=4 )