Jump to content

Adding a field to templates


alxndre
 Share

Recommended Posts

Hi,

I'm trying to figure out if it's possible to add a "field" of some sort to the templates. See, this "field" isn't exactly a like the regular fieldtypes that would have different values depending on the pages that use that template.

What I'm looking for is almost exactly the same as the Tags field in the advanced tab of the template settings. My use case scenario is that I want to put some keywords in there that would be available to all the pages using a particular template, and then I could perhaps use those values to determine dependencies, etc. I could actually achieve this with the existing tag field, but then it messes with the templates list because they appear multiple times depending on how many tags I put in them.

So my question is how or if it's possible to add another field like it to templates?

Thanks. :)

Link to comment
Share on other sites

@Alxndre', you may find some useful snippets in my Template Parents module(s) as a starting point. For historical reasons, the hooks into the Template methods for injecting the field markup and for triggering storing of the value are in TemplateParents.module, while the creation of the necessary database table and the save/load logic itself is in ProcessTemplateParents.module, but all of these could easily be combined into a single module file.

Link to comment
Share on other sites

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...