Jump to content

Getting some pages, except the current one


Recommended Posts

I want to display a list of news items (= pages) in the sidebar. Of course, the current page should not appear in this list – even if it would match the criteria.

So I tried

$current_page_id = $page->id;
$all_news = $pages->find('template=news, id!=$current_page_id, sort=-news_date');

But that doesn’s work. I get the error message “Selector operator: '!=$' -- was your selector value properly escaped?”. But all examples have no excaping. So what’s wrong?

Link to comment
Share on other sites

You can shorten it a bit when excluding the current page to be id!=$page

When you don't specifically pull out a field from a $page object it simply returns the ID.

Not a lot of people know that, but it can be handy.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...