1063Selector Magic in ProcessWire

ProcessWire's way of selecting ("getting") child pages is usually like this:
Get all children

$events = $page->children();

This can be fine-tuned with the Selector string.
Get all children, where the date or end_date is later than today, sort the results by date.

$events = $page->children("date|end_date>today,sort=date");

This works great, by we recently had a case, where a schedule talk had to be postponed to an unknown date in the future. I left the date field in the Backend empty, we need to modify the selection string:
Get all children, where the date or end_date is later than today OR where date is empty, sort the results by date.

$events = $page->children("(date|end_date >today), (date=), sort=date");

It's beautiful, that it's just a small change in the selection string:

  • The additional parenthesis () around (date|end_date >today) and (date=) specify an OR relation. Default is AND, here it means: select children with either (date|end_date >today) OR (date=) - no date.
  • date= means that the date field is empty

Resources

872Funky CSS Selectors

https://www.w3.org/TR/css3-selectors/#attribute-substrings

[att=val] code[class="language-"] { } <code class="language-c language-js"> Represents an element with the att attribute whose value contains at least one instance of the substring "val". If "val" is the empty string then the selector does not represent anything.
[att^=val] Represents an element with the att attribute whose value begins with the prefix "val". If "val" is the empty string then the selector does not represent anything.
[att$=val] Represents an element with the att attribute whose value ends with the suffix "val". If "val" is the empty string then the selector does not represent anything.

484Printing Selectors in NSLog

Using NSStringFromSelector to convert the selectos into a NSString, and the print the object:

NSLog(@"%@", NSStringFromSelector(selector) );

Or print it directly with good, old-fashioned C:

NSLog(@"%s", selector,);

37Perform method in Background

[self performSelectorInBackground:@selector(method) withObject:nil];

& wrap method in autorelease pool.

maybe also of interest: http://code.google.com/p/plactorkit/ Dictated but not read.