Jump to content

Meaning of Family Setting: Can this template be used for new pages?


aldumas
 Share

Recommended Posts

I'm new to PW and a little unsure of what "Can this template be used for new pages?" means. The behavior I am seeing does not fit my intuition and I am hoping someone can help me understand.

I created a new template and then a page that uses it. Then I went back to the template family settings and selected "No" for "Can this template be used for new pages?" thinking that I would no longer be able to use this template when creating a new page.

But when I went to create a new page, the template was selectable from the droplist, and PW let me save the page. I expected that the template would not be visible in the droplist, and even if it were, I expected PW to prevent me from being able to save a page that tries to use it.

I am using ProcessWire 2.6.

Thanks for your help!

Link to comment
Share on other sites

That the template is still visible in the dropdown is not how it should work. The second part is different. In the backend there could be a "second" check after submission of the page-add form and before the page will be finally saved, but really hiding it from the dropdown should be enough (as long as it works). From the pure api side there's no restriction to prevent the addition of new pages. 

Link to comment
Share on other sites

I can't reproduce this. When not allowjng to create new page with the template, I can't select it (means it's not there) when adding a new page.

Here are my steps to reproduce using ProcessWire 2.6.1. Will you please give it a try?

1. From menu, click Setup -> Templates -> Add New.
2. Input template name, e.g. "justonepage".
3. Click Add Templates.
4. From menu, click Pages.
5. Click New next to Home page.
6. Input title, e.g. "Page Uses My Single Page Template".
7. Choose template from step 2.
8. Click Save.
9. From menu, click Setup -> Templates -> (name of template from step 2).
10. Click Family.
11. Select "No" for "Can this template be used for new pages?".
12. Click Save.
13. From menu, click Pages.
14. Click New next to Home page.
15. Input a title, e.g. "Some other page".
16. Click Save.
17. Click Settings.
18. Click the Template dropdown.
 
The template created in step 3 is present in the droplist.
 
Thanks!
Link to comment
Share on other sites

But that's not creating a new page, but changing an already created page. As I remember it was always like this.

OK. I guess that would explain it. I was hoping to be able to use a template exactly once for a page (for content to be reused across multiple web pages) and then make it not visible in the droplist going forward (even page edits) so as not to confuse clients.

Thanks, everyone, for clearing things up for me!

Link to comment
Share on other sites

Just for the record, this is also discussed here: https://github.com/ryancramerdesign/ProcessWire/issues/263. In that issue Ryan explains why it works like it does.

Generally speaking I'd suggest avoiding changing templates of existing pages, and explaining to clients that this is a) a special case, and b) potentially dangerous. Changing template could result in loss of data (though ProcessWire does attempt to warn you before anything irreversible can happen), and it might also cause unexpected side-effects on the site, if something somewhere assumes that a specific page exists and is of certain type, etc.

  • Like 1
Link to comment
Share on other sites

Just for the record, this is also discussed here: https://github.com/ryancramerdesign/ProcessWire/issues/263. In that issue Ryan explains why it works like it does.

Generally speaking I'd suggest avoiding changing templates of existing pages, and explaining to clients that this is a) a special case, and b) potentially dangerous. Changing template could result in loss of data (though ProcessWire does attempt to warn you before anything irreversible can happen), and it might also cause unexpected side-effects on the site, if something somewhere assumes that a specific page exists and is of certain type, etc.

Good advice, thanks! I also hadn't played around with roles much, but I now see that we can create a role that can't change templates on pages. Nice!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...