Jump to content

FieldtypeReference


LostKobrakai
 Share

Recommended Posts

Another small, but potentially helpful module. 
 
This fieldtype references a field in a page, where the field's data is retrieved from a somehow related remote page. It's kinda like a one way symlink to a remote field. To make this description a little easier to understand I'll just add a example.

Imagine you've some pages placed all over the page-tree, but you need editors to be aware of a specific setting in a single page. With this Fieldtype you would set this up like this:

- Get the page (php snippet kinda like for page fields)

return $pages->get("/special-settings-page/"); 

- Setup template to field pairing

settings=my_special_field 

- Add this field to any template you need this on.

Now this special setting is visible in the backend, if someone edits a page with this reference field, and via the api as read-only field. The field can use all collapsed modes, which do not allow editing, so it can be hidden if it's only needed by the api.

This can be useful for content heavy sites, where information is scattered around multiple (parent) pages, but maybe all information needs to be available for the children. It's also nice for creating (shorter) selectors for inputfield dependencies or dynamic page fields. More elaborate examples about this options can be found in the readme of the module.

Todo

  • Add checks to prevent infinite loops
  • Maybe make it a field, which can be edited and saved.

 
GitHub: https://github.com/LostKobrakai/FieldtypeReference

  • Like 14
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...