How to exclude current page from pagelist

Permalink 1 user found helpful
Hi everyone
Is there an easy way to exclude the current page from a pagelist?

pixeljunkie
 
Steevb replied on at Permalink Reply
Steevb
In edit mode click gear icon, click attributes, click 'Exclude From Page List'
pixeljunkie replied on at Permalink Reply
pixeljunkie
Hi - thx for your response. I guess I did not pose my question properly.
I have a few pages underneath a parent page, say "Blog". Each of the subpages ("Post 1", "Post 2", ....) contains a content area and a sidebar with a pagelist of the other topics from the branch "Blog". When viewing "Post 1", I would like to exclude the post currently viewed from the pagelist in the sidebar.
Parasek replied on at Permalink Best Answer Reply
Parasek
a) In your pagelist template, just after:

foreach ($pages as $page):


you need to paste:
if ($page->getCollectionID()!=$c->getCollectionID()) {


b) And just before
<?php endforeach; ?>


you need to paste
<?php } ?>




---------------------------

c) I don't remember if it is needed, if yes, then paste it somewhere at top of the file
$c = Page::getCurrentPage();
pixeljunkie replied on at Permalink Reply
pixeljunkie
Works like a charme!! Thanks for your help!!!!
somesayinice replied on at Permalink Reply
Here's another way:
$cID=Page::getCurrentPage()->getCollectionID();
$pl = new \Concrete\Core\Page\PageList();
$pl->getQueryObject()->where("(p.cID != $cID)"); //Please note, this needs to be first as it will undo any other filtering you have done.