|
This post originated from an RSS feed registered with PHP Buzz
by Forum One.
|
Original Post: Simplified filtering by Parent
Feed Title: Syntax Framework
Feed URL: http://blog.syntaxcms.org/rss.php?version=0.91
Feed Description: Finally, a place to answer Syntax questions
|
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Forum One
Latest Posts From Syntax Framework
|
|
Filtering by a parent object, such as a seciton, was previously a needlessly complicated process that involved setting up a parent filter and adding it to your main filter via add_parent, as show below:
$sectionFilter =& pxdb_search::filter(DATATYPE_SECTION);
$sectionFilter->add_value('id', $Request->getVar('in_section'));
$content_filter->add_parent($sectionFilter);
The latest CVS snapshot simplified add_parent by allowing it accept either a pxdb_search filter, a pxdb_record or descendant object, a numeric record id, or a record's idnum value. This makes it easier to filter by parent objects since any of the following are now valid calls. The add_parent() method will handle all the filtering internally.
$content_filter->add_parent( $Section ); // seciton is a pxdb_record descendant
or
$content_filter->add_parent( $Section->get_id() );
or
$content_filter->add_parent( $pxdb_record->get_field( 'idnum' ) );
Read: Simplified filtering by Parent