We have a blueprint with a field related pages. How can i display them in the layout table? What i get now is - page://5AjfQpOX6gle0hFD. i would like to display the related page title…
This is possible when you override the page class:
Example:
public function relatedPagesString(): string
{
$relatedPagesTitles = [];
$relatedPages = $this->related()->toPages();
foreach ($relatedPages as $p) :
$relatedPagesTitles[] = $p->title();
endforeach;
return implode(',', $relatedPagesTitles);
}
But we also need to be able to override the files class as we also use the related pages on files to be able to give them tags…
Question: how to do this for files?
You can use a file method instead of a model method.
The code above could be simplified:
$relatedPagesTitles = $this->related()->toPages()->pluck('title', ',');
return implode(',', $relatedPagesTitles);
Yes, this works, no i can display related pages (= tags) in the layout table, BUT i cannot search for a related page… Is there a solution for this? To also include the column file method in the search? Or is there another way?
In files search, you mean?
Not out of the box. You probably have to change how the search works.
Ok, so the easiest would probably be use a hook and store the page title (=tag) information also in a text field
Yes, I think so, maybe use a hidden field for that purpose.
