Table layout: display related pages titles

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?

I can search in the files (title, name,) but i use the related pages a tags for the files. So i have over 10.000 documents, the user needs to be able to search the tags (ex. Tag 1) or even better have a tag filter dropdown. Can this be done?

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.