Reference a specific Tailor record from a yaml file with traditional form fields

I wanted to point to a Tailor record from a theme configuration file (which is a yaml file with traditional field types). Specifically I wanted to display a dropdown with all the Tailor records of a specific handle in my theme settings.

In this context the field types Mixin and Entries are not available.

So I decided to take a contrived route by creating a traditional formwidget called “publicationpicker”.
Publications here being part of my Tailor blueprint “Library\Publication” of the type stream.

But, knowing October CMS and its simplicity, my gut tells me this is much too complex for the goal I wanted to reach.

Some details about what I wanted to attain:

  • Back-end: Dropdown in the back-end that looks for publications of all sites in the multisite environment, not just the context of the current site.

  • Front-end: Display the record information (ignoring the site context the visitor is currently on) and linking to the original publication on the original site.

The idea would be that the administrator can select a publication of a specific site to be displayed, keeping its original context, and disregarding the site context the current user is on.

As said I managed to solve it, but in a much too complicated way, and I’d love some insights on this.

The docs touches on this: Models - October CMS - 4.x

You’d need to create a belongsTo relation in the Theme config model and then add a form field (relation or recordfinder) to provide the UI.

Thank you Sam.

I have a custom pagebuilder that uses the Rainlab Pages plugin. Is it the same idea there?

And lastly: is this also applicable to v3?

I’ve not yet switched over to v4 yet because the Docker image is locked to v3 and I’d like to do more testing before making the jump.

Not quite, the Pages plugin doesn’t use traditional models (it is file-based), so it doesn’t allow for fully-qualified Eloquent relationships. That’s actually one of the issues that Tailor solves.

1 Like