Jump to content

New Template Family Setting: Single Child


wheelmaker24
 Share

Recommended Posts

Hi,

I got a new idea which come in handy when creating ProcessWire pages with enclosed subsections. Currently within the template family settings there is a setting "Can this template be used for new pages?" with the options "Yes", "No" and "One". My proposal is to add a fourth option that is "Single Child". This would allow the template to be created only once within another page (meaning that there wouldn't be any siblings with the same template).

To give you an example look at this page structure for a multi-site webpage:

  • Newsroom root
    • Newsroom for Country 1
      • News articles
        • Article 1
        • Article 2
        • ...
      • Tags
      • Search
      • 404
    • Newsroom for Country 2
      • News articles
      • Tags
      • Search
      • 404
    • Newsroom for Country 3
      • ...

The root template will automatically redirect to the country newsroom page according to the browser's locale settings. Within each country newsroom there should obviously only be one "Tags", "Search" and "404" template. The option mentioned above would enable me to do this.

A work-around solution for my specific use-case would be to select the option "No" and automatically create the Country Newsroom's children via a hook that triggers when a new country newsroom page has been created. But I think that this fourth option could come in handy for other use-cases as well.

What do you think?

Link to comment
Share on other sites

While I agree that Dave's statement might be a very specific need, I think that both "One" and "Single Child" options have their purposes. Besides the use-cases mentioned above, you could use it for the following:

  • A "config" page for specific pages (e.g. when having a portal with sub-portals you could add a "config" page as a child to each sub-portal and there configure theme, navigation, ...):
    • Sub Portal 1
      • Config Page
      • Page 1
      • Page 2
      • ...
    • Sub Portal 2
      • Config Page
      • ...
    • Sub Portal 3
    • ...
  • When using a folder strategy for the page tree, you could use it for sub-pages like "Attachments", "Comments", ... that may be added once to every page without canibalizing the page hierarchy, e.g.
    • /page1/
    • /page1/comments/
    • /page1/attachments/
    • /page1/subpage1/
    • /page1/subpage/1/comments/
    • /page1/subpage2/
  • When having a registration system with the following page structure, "Events" and "Registrations" pages should have the "Single Child" option enabled:
    • Conference 1
      • Events
        • Event 1
        • Event 2
        • ...
      • Registrations
        • User 1
        • User 2
        • ...
    • Conference 2
      • ...
    • Conference 3
    • ...
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

×
×
  • Create New...