I have a complex situation, I think
I have a template of a book page. I have several books there already.
Each book has a field of tags and there are multiple tags for each book.
Important: The tags are pages too!
I have another template of magazine page. In this page the user picks 5 book pages (from book pages list) that are related to this magazine page.
I would want to have a related book pages to this magazine page according to the picked books’ tags.
between book pages I use this script to get all related books that has 1 or more same tags:
$tags = page('books')->children()->not($page)->filterBy('tagss', 'in', $page->tagss()->split(','), ',')
but if I want to get al related books to a magazine page (that has tags of 4 books) I get a little confused.
I tried this, just to see if I can get a list of the tags but it gives me error:
<?php $book_picks = $page->picks()->toPages(','); $pick_tags = $book_picks->tags()->toPages(','); echo $pick_tags ?>
I guess that I need to use foreach, but then I wonder how can I use it as a variable inside the filterBy.
I hope Im being understood. Thanks for the help!