Hi, I'm new here, I'll start by posting in an existing thread ;-)
I'm trying to do something similar than the OP, but I can't get it to work :
- I have pages with template "one-category", where each page represent one category
- I have pages with template "one-article", which are used for the actual contents.
- one of the fields of "one-article" is "article_categories", it is of type "Page", more specifically "Multiple pages (PageArray)". It is used to reference a list of pages of type "one-category" (which means it is used for assigning categories to each article).
Now, I want to select, for each existing category pages, the list of the "one-article" pages which are referencing the category.
For troubleshooting, I also try to "just" select all the "one-article" pages which are referencing one single category page.
here is the code :
$the_articles = $pages->find("template=one-article"); // select all existing real pages
$the_cat = $pages->get("template=one-category, title='cat1'"); // select one category page
$the_list = $the_articles->find("article_categories=$the_cat"); // select real pages referencing the desired category page
as a result,
- this is working if I have only 1 category referenced in the articles : $the_list->count() returns '1' for the relevant article, and I can use the returned objet
- but it (seems to) fail as soon as I add a second category to this article : $the_list->count() now returns '0', while I would expect it to still return '1'
any idea ?