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?
Is there an easy way to exclude the current page from a pagelist?
In edit mode click gear icon, click attributes, click 'Exclude From Page List'
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.
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.
a) In your pagelist template, just after:
you need to paste:
b) And just before
you need to paste
---------------------------
c) I don't remember if it is needed, if yes, then paste it somewhere at top of the file
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();
Works like a charme!! Thanks for your help!!!!
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.