I got an asset field called docs
which is contained in 2 different entries.
Those entries are in different sections and they contain the docs
field directly or through a matrix field called articleBody
.
I made two queries relatedTo and merge them thereafter.
It works but would it be a better way by combining the two queries in one relatedTo call?
Query 1: pages
section entries contain docs
field inside a matrix field called articleBody
Query 2: library
section entries contain docs
field directly
$criteria1 = craft()->elements->getCriteria(ElementType::Entry);
$criteria1->section = 'pages';
$criteria1->relatedTo = array(
'targetElement' => $asset->id,
'field' => 'articleBody.docs'
);
$criteria2 = craft()->elements->getCriteria(ElementType::Entry);
$criteria2->section = 'library';
$criteria2->relatedTo = array(
'targetElement' => $asset->id,
'field' => 'docs'
);
$criteria = array_merge($criteria1, $criteria2);