Jump to content

Recommended Posts

Posted

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?

Posted

You can't put php variables inside single quote string, only double quotes are getting parsed.

No need to use remove(), the selector is the easiest way.

  • Like 1
Posted

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

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
  • Recently Browsing   0 members

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