Michael van Laar Posted July 5, 2012 Share Posted July 5, 2012 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 More sharing options...
Michael van Laar Posted July 5, 2012 Author Share Posted July 5, 2012 Solved! Using double quites instead of single quotes does the trick. Link to comment Share on other sites More sharing options...
diogo Posted July 5, 2012 Share Posted July 5, 2012 You can use $array->remove($page) As Soma likes to do: http://processwire.c...->remove($item) Link to comment Share on other sites More sharing options...
Soma Posted July 5, 2012 Share Posted July 5, 2012 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. 1 Link to comment Share on other sites More sharing options...
Pete Posted July 9, 2012 Share Posted July 9, 2012 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now