Jump to content

sorting pages with exception


ngrmm
 Share

Recommended Posts

i'd like to have a list of pages sorted by „creation“.

$articles = $pages->find("template=x|y, sort=creation");
 

all the pages have a checkbox-field. the name of the checkbox-field is highlight.

and it is a autojoin-field.

i want all the highlight-pages listed above the others

i don't know how to handle checked and not checked as a value

this doesn't work

$articles = $pages->find("template=x|y, sort=highlight,  sort=creation" );

Link to comment
Share on other sites

i solved it this was:

$articles = $pages->find("template=photo|video, highlight=1, sort=created, ");
$articles_2 = $pages->find("template=photo|video, highlight=0, sort=created, ");
 
but it seems there could be a better way with less code
Link to comment
Share on other sites

Hi ngrmm,

the value of a checkbox is 0 for unchecked and 1 for checked, so to have checked pages at the top, you have to sort in descending order. Simply prepend a - to the field:

$articles = $pages->find('template=x|y, sort=-highlight, sort=creation');
  • 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

×
×
  • Create New...