How to create page template with a custom field (or any sort of model), e.g. an ID or code?
All the tutorials create page templates either via the UI or via crxde editor. This will create a template on a running instance, not our our source code, so wont get deployed to any of the environments. This is the first issue.
The second problem is that when you create a template via UI, there does not seem to be a way to add any fields to it.
for example, if we want to create a template for holiday destinations, we could do this via ui, and drag some components such as images or text blocks. But how would we add a fields, such as holiday ID, country ISO code etc, so that
a) we can search for holidays via code (e.g. in a servlet)
b) when the user clicks on a CTA in a holiday, we can some how get the pages holiday ID?
We see there are three types of template: static, editable, and template-type. Do any of these support custom attributes/model, and do either support creation of the template in code, so that it can be deployed to other environments, not just exist on the developers local running AEM server? There seem to be no tutorials on creating template-types, so we are guessing that creating a static template might be easier (if we can find a tutorial to do it in code, rather than UI on a running server)
This page has some partial how how to create a template in CRXDE, which presumably we can some how import into our code, but there is no info on how to add any attributes or custom fields to the template. We could of course create a component and add this to the template, as there is an easy way to create components in code and give them a model, but we have not found this feature for page templates.