webhoes Posted December 16, 2017 Share Posted December 16, 2017 Hello, I am playing with pw-regions. Normally I make a _main.php with the basic layout with a content region. For templates that need a different content region I override the complete content region that includes basic layout and also make a copy of the sidebar. Side effect is that if I change the sidebar I need to change it on several templates. Now I am working on this. Now _main.php I make two body regions (body and body-sidebar). One with sidebar and one without. Within these regions a make region content and a region sidebar. //without sidebar <pw-regiond id="body"> //some html <pw-regiond id="content"> //some html </div> //some html </div> //with sidebar <pw-regiond id="body-sidebar"> //some html <pw-regiond id="content"></div> //some html <pw-regiond id="sidebar"> //some html </div> //some htm </div> On the other templates I output a specific content through the content region done by functions. If I don't need a sidebar I override the region <pw-region id="body-sidebar"> with nothing. If I do need a sidebar I override <pw-region id="body"> with nothing. The content regions always outputs in the visbile body in the conent region. Also the sidebar is a region (sidebar). If outputted I can append or prepend to it. I works but is it a correct method. I am currious to know if this slowsdown the side because of extra rendering. What could be other strategies to get this flexibility? Link to comment Share on other sites More sharing options...
bernhard Posted December 16, 2017 Share Posted December 16, 2017 hm... not sure why you have <region...></div> in your example? you could also use a variable + if in your _main.php: // _main.php if($config->sidebar) { // your sidebar markup // grid // region body // region sidebar } else { // no sidebar // region body } and in your template file $config->sidebar = false; <region id="body">your content</region> // or $config->sidebar = true; <region id="body">your content</region> <region id="sidebar">your sidebar</region> but i think there's also nothing wrong about setting regions to null Link to comment Share on other sites More sharing options...
webhoes Posted December 16, 2017 Author Share Posted December 16, 2017 7 hours ago, bernhard said: <region...></div> Ahaa... I meant ofcourse <pw-region> </pw-region> If I understand correctly I still have define the html in the different templates. That would not be different from what I have no (not they way described above). If there is a structural change in the template, I need to change them all. In my case every template has the same basic layout but different content that is outputted with a function where I render the layout of that specific content. That's why I was thinking of defining a region for the layout and within that a region for the content. To seperate the layout and the content. I just playing with the possibilites and hope to get to use them clever. Link to comment Share on other sites More sharing options...
Robin S Posted December 16, 2017 Share Posted December 16, 2017 You can nest as many regions as you want, so long as they are all defined in _main.php. In other words, the only limitation is that you can't define new regions in a template file that is then included in another template file. So despite the first blog post on Markup Regions saying... Quote By that token, the elements that you manipulate don't even have to be part of the main document markup. This template strategy can be nested and go recursive. Meaning you can manipulate something you added from a template file or some other include(), which could be useful in certain cases where you might want it. ...Ryan later decided to remove this feature. If you are concerned about performance remember to use markup region hints to make the regions parsing more efficient. 1 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