Hi there,
I’m having difficulties modifying the base wrapper so I can have the following two (very common) layouts without losing the DRY principle:
1) Fullwidth element (created in custom template) with underneath the normal main content in a container.
+----------------------------------------+
| header |
+-------------+----------------------------------------+------------+
| |
| |
| |
| fullwidth content |
| |
| |
| |
+-------------+----------------------------------------+------------+
| |
| |
| |
| |
| main content |
| |
| |
| |
| |
| |
+----------------------------------------+
2) Fullwidth element (created from custom template) with underneath the normal main content including the sidebar in a container.
+----------------------------------------+
| header |
+-------------+----------------------------------------+------------+
| |
| |
| |
| |
| fullwidth content |
| |
| |
| |
+-------------+--------------------------+-------------+------------+
| | |
| | |
| main content | sidebar |
| | |
| | |
| +-------------+
| |
| |
| |
+--------------------------+
I know I can make a separate base template for each custom template, but that doesn’t really make much sense to me. Let’s say I have 4 different templates which all have different fullwidth elements created by different template parts and I want to keep the possibility to enable or disable the sidebar for each template.
First I would have to make the 4 custom templates (without the fullwidth elements) in order to use the custom base wrappers per template in which I could call the fullwidth template parts without a container and before the main content.
Then you basically have 4 identical base wrappers with only one get_template_part
different?
Another way would be to remove the container class from the wrap and the row class from the content and remove the sidebar altogether. But that would mean that you have to repeat the sidebar conditional in EVERY template:
<?php if (Config\display_sidebar()) : ?>
<aside class="sidebar" role="complementary">
<?php include Wrapper\sidebar_path(); ?>
</aside>
<?php endif; ?>
Both methods don’t really follow the DRY principle…
Is there another smart way to achieve this which I’m overlooking?
Thanks!