PageList - filtering by custom attribute with comparison
Permalink
Hello, Everyone!
I have a custom page attribute (Multi-Page selector) that contains array of related pages IDs. How can I filter this attribute with the PageList object by "equal" comparison?
Methods, like this:
$pl->filterByAttribute('related_pages', $this->pID, "=") or
$pl->filterByAttribute('related_pages', "$this->pID", 'like');
give an Doctrine\ DBAL \ Exception \ InvalidFieldNameException - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ak_related_pages' in 'where clause'.
This attribute is included in the search index.
Thanks, Nick.
I have a custom page attribute (Multi-Page selector) that contains array of related pages IDs. How can I filter this attribute with the PageList object by "equal" comparison?
Methods, like this:
$pl->filterByAttribute('related_pages', $this->pID, "=") or
$pl->filterByAttribute('related_pages', "$this->pID", 'like');
give an Doctrine\ DBAL \ Exception \ InvalidFieldNameException - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ak_related_pages' in 'where clause'.
This attribute is included in the search index.
Thanks, Nick.
This sounds like "related_pages" might not be the Handle that's defined for your Page Attribute.
Unfortunately, no, the attribute handle is defined correctly. The wrong handle gives "Unable to find attribute" exception.
Because it is an array. You likely will have to run the query and then filter against the extracted values from your multi-select. That is what I had to do for v5.6, though current versions may be different. Who know with the paucity of documentation though.