Resource link patterns: make commented records clickable
Describes Comments 0.6.0.
On the Comments moderation page, each comment shows a chip naming the record it was left on. A resource link pattern turns that chip into a link to the record’s page, with a readable title, for record types that don’t already say where they live.
Where to find it
Open Settings, then Comments, then the Resource Link Patterns tab (/admin/settings/comments). You need the Change the comments settings permission.
Most record types don’t need a pattern. Core’s own types and the PhoenixKit modules’ records are linked by their module, and a module’s link always wins over a pattern. You need a pattern for a type that comes from the host app itself, such as comments a developer placed on the site’s own order pages.
Writing a pattern
A pattern has two parts:
- Path: where the record lives on this site. It must start with
/or:prefix, must stay on this site, and must contain:uuid(the record’s ID) or:metadata.KEY(a value stored with the comment).:prefixputs in the site’s URL prefix. The page gives the examples/products/:uuidand:prefix/admin/shop/:uuid. - Display title: what the chip says, for example
:metadata.slug. Left empty, the table shows UUID (default).
When the comments of a type carry extra values, Available fields: lists them as :metadata. badges under the boxes. Click a badge to put it into the box where your cursor was.
A pattern that breaks the rules isn’t saved, and the page says why, for example Path template must start with / or :prefix or Path template must contain :uuid or :metadata.KEY placeholders.
Adding a pattern
- Resource types without link patterns: types that have comments but no link yet, each with its comment count and its own Path and Display title boxes. Fill them in and click Add. A type a module already links isn’t listed here.
- or add manually: the form at the bottom takes a Resource Type, a Path and a Display title, for a type that has no comments yet. Click Add.
Added path for and the type name confirm it.
Changing or removing a pattern
Saved patterns are listed in a table with Resource Type, Path Template and Display Template. The pencil button opens the row for editing, with Save and Cancel. The trash button removes the pattern after you confirm Remove path pattern for the type.
Patterns are kept apart from the other comment settings: Save Settings and Reset on the other tabs don’t change them.
What it doesn’t do
- It doesn’t replace a module’s own links. For a type a module links, a pattern is never used.
- It doesn’t check that the page exists. A pattern pointing at a wrong path makes a broken link.