OpenBayou Posted November 4, 2016 Share Posted November 4, 2016 Hello, I'm new to ProcessWire and need help. I have a page called Ad and each page underneath will be a post about a particular advertisement. I want to be able to use different template for the parent page and the children page or can i use one template file and use if parent and if children. Link to comment Share on other sites More sharing options...
adrian Posted November 4, 2016 Share Posted November 4, 2016 The usual approach would be an "advertisements" (plural) template for the parent page and an "advertisement" (singular) for the child pages - that will give you the most flexibility in controlling the Family settings so that all child pages must be of that advertisement template when created. There are other approaches, but this will be the simplest/most flexible while you are learning the ropes! 2 Link to comment Share on other sites More sharing options...
horst Posted November 4, 2016 Share Posted November 4, 2016 additionally to what @adrian said, it is possible to define those both templates in the admin, one plural and one singular, to build a family out of them. But if you like, you can use one template file for both. If you have created an advertisements.php under site/templates/, create the plural template first. When creating the singular template, select ceate a template without template file in the first screen, (write your singular template name into the input box, without the fileextension). Save, open again and head to the tab [files]. There you select to use an alternative template file, your plural template file. Now you have two templates for easy sort between parent and children, and one templatefile that renders your markup. If you want to render it the same, do nothing special. If you want to render parent and children different, you can check the template name like // this block is skipped by child pages if("advertisements" == $page->temlate) { // chek for plural / parent template // do your stuff ... return; // end template file processing here for all parent pages } // do your stuff for child pages (single template pages) here, ... ... 4 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now