It would be great to be able to specify a default template per node.
Defaults could be set on the content type admin page, similar to how better formats introduces an "input format settings" tab. A drop down selecting the default template would be swell.
Configuration could be extended to allowable templates. Checkboxes could provide the option to include/exclude templates per node type.
In our use case, we are trying to provide by default a 2-column layout on pages. Some pages use an optional single column template. We don't want to offer templates at all on news pages, especially 2-column ones.
Comment | File | Size | Author |
---|---|---|---|
#6 | #1260246_Default_Template_per_node_type.patch | 21.79 KB | jurgenhaas |
Comments
Comment #1
guybedford CreditAttribution: guybedford commentedThanks for sharing your use case. In terms of how it fits in with this module, it is actually a very different functionality in what this offers.
If I understand right, you are suggesting that for each content type you would like a default template to automatically populate in the body field. This can be done quite simply with the following module hook:
Then in terms of permission-based templates for content types or roles, this is certainly a feature that can be offered given enough support.
Hope that helps.
Comment #2
Andrew_Mallis CreditAttribution: Andrew_Mallis commentedThanks for the code (and your work on the module). Great stuff! I will definitely employ that.
The kind of templates offered up for static content, or blocks differ from those on blog posts, for example. Blog posts might not even deserve a template.
This is icing, though, and food for thought.
Comment #3
guybedford CreditAttribution: guybedford commentedActually yeah I get you... it is a very useful feature to set templates per node, and then optionally have a default template auto-populate when creating content.
Will see if I can add this in over the next couple of weeks.
Comment #4
chichilatte CreditAttribution: chichilatte commentedWould love to see this as part of the module, yup. Thanks for your hard work!
Comment #5
guybedford CreditAttribution: guybedford commentedAny patches for this feature would be more than welcome.
Comment #6
jurgenhaasNo I got around to implement this and attached is a patch which does the following:
The attached patch is a little bit larger because my IDE has also reformatted the code of the whole module so that it is now compliant with the Drupal coding standards.
Comment #7
guybedford CreditAttribution: guybedford commentedThanks Jurgen - this looks great.
I'm seeing everything work, except when inserting a template, it isn't selecting the default one. I'm using CK Editor 3.5.2 - perhaps I need to update.
I like the way this is structured a lot. It could also be useful to allow filtering the available templates by content type. So articles only see some templates etc. But that's just a suggestion.
Please feel free to commit these changes to the dev branch. I trust your judgement at this point, then just let me know when you think you are nearing a release point and I will do a review for release.
Comment #8
jurgenhaasThanks Guy for your quick response. Having two issues:
1) I can't push the code back to the dev release, I get a 403-error. Maybe I haven't got permission yet?
2) You're saying "it isn't selecting the default" one and I'm a bit confused by that. If a default template is defined for a content type, then that template will already be there if you open the node edit form, you don't have to select that template from the list anymore. And that works completely independant from the used editor, because the template is inserted into the body field before the form gets delivered to the browser.
So, that sounds as if something is not correct in your installation yet. Maybe we postpone that until we have the code in the repository.
Comment #9
guybedford CreditAttribution: guybedford commented1) All the maintainer permissions are definitely enabled. You have every permission except Administer Maintainers. Can you try again? I'm not sure what else I can do this side.
2) Oh right - sorry I didn't understand that this was the behaviour. That sounds really great! We should document this as well when it is released.
Comment #10
jurgenhaasThe push now worked OK, for some reason I had to clone my working copy from source again, something was wrong with the first one.
Now let's test and finalize this feature with defaults per content type and then I'd love to continue with what you mentioned as well: optionally assign each template to one or many content types, so that these templates only show up there.
Comment #11
guybedford CreditAttribution: guybedford commentedSure, let me know if you're thinking of working on the filters before or after the release. Either works for me. If you do want to release it now first, I'm more than happy with that - will just do a final code review.
Comment #12
jurgenhaasFor some reason, my last comment didn't get posted. I have included the filters so that templates can be limited to certain content types and if everything got reviewed successfully, we are ready for a new release.
Comment #13
guybedford CreditAttribution: guybedford commentedAmazing, this is all working great, and the updates are running smoothly for me.
Happy to release when you are.
Comment #14
jurgenhaasThat's great, thanks Guy for the review. I'm going to release all the changes just now.