В информационной системе есть два доп.свойства типа флажок. В зависимости от условия надо выбирать элементы либо по первому доп.свойству либо по второму.
Делаю так:
if ($page_type == 'news') // новости
{
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('СписокСтатейИМатериаловNew')
)
->addEntity(
Core::factory('Core_Xml_Entity')
->name('ОтображатьСсылкиНаСледующиеСтраницы')->value(1)
)
->group($group_id)
->limit(8);
// Объединение с нужной таблицей свойств
$Informationsystem_Controller_Show
->informationsystemItems()
->queryBuilder()
->leftJoin('informationsystem_item_properties', 'informationsystem_items.informationsystem_id', '=', 'informationsystem_item_properties.informationsystem_id')
->leftJoin('property_value_ints', 'informationsystem_items.id', '=', 'property_value_ints.entity_id',
array(
array('AND' => array('informationsystem_item_properties.property_id', '=', Core_QueryBuilder::expression('`property_value_ints`.`property_id`')))
)
)
// Идентификатор дополнительного свойства
->where('informationsystem_item_properties.property_id', '=', 8)
// Значание дополнительного свойства
->where('property_value_ints.value', '=', '1')
->clearOrderBy()
->orderBy('datetime')
// Количество свойств
->having(Core_Querybuilder::expression('COUNT(DISTINCT `informationsystem_item_properties`.`property_id`)'), '=', 1)
;
}
elseif ($page_type == 'articles') // статьи
{
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('СписокСтатейИМатериаловNew')
)
->addEntity(
Core::factory('Core_Xml_Entity')
->name('ОтображатьСсылкиНаСледующиеСтраницы')->value(1)
)
->group($group_id)
->limit(8);
// Объединение с нужной таблицей свойств
$Informationsystem_Controller_Show
->informationsystemItems()
->queryBuilder()
->leftJoin('informationsystem_item_properties', 'informationsystem_items.informationsystem_id', '=', 'informationsystem_item_properties.informationsystem_id')
->leftJoin('property_value_ints', 'informationsystem_items.id', '=', 'property_value_ints.entity_id',
array(
array('AND' => array('informationsystem_item_properties.property_id', '=', Core_QueryBuilder::expression('`property_value_ints`.`property_id`')))
)
)
// Идентификатор дополнительного свойства
->where('informationsystem_item_properties.property_id', '=', 9)
// Значание дополнительного свойства
->where('property_value_ints.value', '=', '1')
->clearOrderBy()
->orderBy('datetime')
// Количество свойств
->having(Core_Querybuilder::expression('COUNT(DISTINCT `informationsystem_item_properties`.`property_id`)'), '=', 1);
}
$Informationsystem_Controller_Show->show();
В обоих случаях выводятся один и те же элементы.