Maybe I’m not reading the docs well enough, but this is not clear for me:
Let’s say I want to use a shared default.yml page template, but a different template.php file than default.php:
Lets use Contact as an example.
If I create a new page “Contact”, and use the Default blueprint, it creates a “Contact” folder within my content folder, with a file of default.txt. This in turn defaults to using the default.php template.
If however the default.txt file would be named contact.txt, I could easily just create a contact.php template for that to be used instead.
How can I make that the default? Meaning, that .txt file takes the name of the slug rather than the name of the template?
That’s not possible, or at least not out of the box. But does this make sense, unless for very specific cases? Considering there will most likely be no huhuhu.php template, and no testme.php template, if a user creates those pages. Also, say you create a contact.php template, and the user decides to give the page a slug contact-us?
Of course, they would all fall back to the default.php template if there is no specific template, but I don’t really see an advantage here.
What you can do is overwrite the create() page method in the DefaultPage model and set the template manually from the slug.
Fair enough! I guess I don’t necessarily try to advocate any changes in how it works, but mainly try to understand the simplest way to use a different template but same blueprint.
If one looks at the docs on how manually creating content works, the naming convention seems to be what I suggested: Creating pages | Kirby CMS (ie. project.txt, blog.txt, contact.txt rather than default.txt x3 in subfolders).
I do agree with you that the risk of changing from contact to contact-us is there, but I guess it also is on the previously mentioned manual creation method from the docs (with corresponding template files). Fallback to default.php is for me logical.
Changing the create() page method feels a bit too heavy handed for my liking, so I’ll probably rather look into a conditional clause in the default.php looking for a slug.php to include or falling back to another sub-default.php if not. Either that or I’ll just keep renaming the .txt files in mind (often the rather static pages like list-overview-pages (articles, calendar), about, contact pages etc.
Let me know if anyone else has a snazzier solution in mind