I have a blog with pages that include a custom Page List block showing the 5 most recent entries in the sidebar. I want don’t want to show the current page in the list if it is one of the most recent entries. However, I always want the Page List to have 5 entries. Currently, if the page is excluded from the list, I only have 4 entries.
I am able to exclude the current page from the list using a custom template View file, however, testing for the duplication while building the $pages array needs to take place in the Controller file, as I need to adjust the $pages array length before sending the data to the View file.
@mnakalay is correct. The only way to do it is to override the controller. I ran into this years ago, where one page would be missing in results just as you describe. In the end I built my own Page List package that handles excluding current page out of the box. No more messing around with templates etc to accomplish this! There’s a WHOLE LOT more built into it than just the exclude page functionality. There’s also a handfull of tweaks and new features about to be released. Have a look here if you’re interested: Enlil Page List - Concrete CMS
@vergedesign why use CSS? You have a loop going through the array of pages. For each page compare the cID to the current page’s cID if it’s the same don’t output it and let the loop run its course. Otherwise, if you reach the last element of the array and still didn’t find the current page, just exit the loop and don’t output the last element.
Very cool, and thank you for the work put in! The c5 community is incredible, and it is one of the many reasons why I have continued to use c5.
I incorporated your PR into my c5 v9 local test site, and while it works when I publish the page, it doesn’t seem to retain the settings when I return to the page. I tried it a number of times, and the setting isn’t sticky.
Also, for consistency, you might want to add a “.” to the end of the checkbox text in the page_list_form.php file, as all of the others in the list have one.