Jump to content

Recommended Posts

Posted

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

Posted

Hmm, I might have misread what you are after.....I thought you want some text to appear in your pages...but it seems you want the templates themselves to be altered in some way...

Posted

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

Posted

It doesn't even need to be stored in a custom db, as most template data is stored as encoded json string anyways, which can be used for custom fields as well.

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
×
×
  • Create New...