Hello guys! Thank you for your replies. To make sure we understand each other, here is the site structure:
- home
|- products
| '- apple
| | |- description page
| | |- features 1
| | |- features 2
| | '- features 3
| |
| |- banana
| | |- description page
| | |- features 1
| | |- features 2
| | '- features 3
| |
| '- orange
| |- description page
| |- features 1
| |- features 2
| '- features 3
|
|- news
| |- news1
| '- news2
|
|- about
'- contact
In the design of the site I have columns as menus, where the left column is the menu for the root-level, the next column the menu for the second level, and finally a third column as the menu for the third level. After that I have the main content. The menus two and three are only rendered if needed.
Eg. for the ‘Contact’ page there is only the first column shown, and then the content for the Contact page.
For the ‘News’ page I have the first and the second column menu, and then the content.
For the ‘Product’ page I have all three columns showing, and then the content.
It should look like this, if the user clicks on ‘Products’ in the first column menu:
Home *Apple *Description *Description for ‘Apple’…
*Products Banana Features 1
News Orange Features 2
About Features 3
Contact
To make this happen I’ve made the following system, starting with the ‘_init.php’:
$menuLevel = count($page->parents);
$homepage = $pages->get('/');
Then I’m using the ‘renderNav’ function in the ‘_func.php’
Then I’m doing custom template files for the pages, here is eg. the product template:
// The secondary and tertiary menus
if($menuLevel >= '1') {
$secondaryNav = renderNav($page->rootParent, 1);
}
if($menuLevel >= '2') {
$tertiaryNav = renderNav($page->siblings, 1);
}
// Primary content is the page's body copy
$contentThree = $page->body;
And then finally it is all rendered in the ‘_main.php’ where the rendering of the menu-columns are dependant on whether the page template needs them.
<body>
<!-- primary navigation -->
<div id="primaryNav">
<ul class='primaryNav'>
<?php
// top navigation consists of homepage and its visible children
foreach($homepage->and($homepage->children) as $item) {
if($item->id == $page->rootParent->id) echo "<li class='current'>";
else echo "<li>";
echo "<a href='$item->url'>$item->title</a></li>";
}
// output an "Edit" link if this page happens to be editable by the current user
if($page->editable()) echo "<li class='edit'><a href='$page->editURL'>Edit</a></li>";
?>
</ul>
<form class='search' action='<?php echo $pages->get('template=search')->url; ?>' method='get'>
<input type='text' name='q' placeholder='Search' value='<?php echo $sanitizer->entities($input->whitelist('q')); ?>' />
<button type='submit' name='submit'>Search</button>
</form>
</div>
<!-- end primary navigation -->
<!-- content with one level of navigation -->
<?php if (isset($contentOne)) {
echo "<div id='contentOne'>";
echo $contentOne;
echo "</div>";
}
?>
<!-- end content with one level of navigation -->
<!-- secondary navigation -->
<?php if (isset($secondaryNav)) {
echo "<div id='secondaryNav'>";
echo $secondaryNav;
echo "</div>";
}
?>
<!-- end secondary navigation -->
<!-- content with two levels of navigation -->
<?php if (isset($contentTwo)) {
echo "<div id='contentTwo'>";
echo $contentTwo;
echo "</div>";
}
?>
<!-- end content with two levels of navigation -->
<!-- tertiary navigation -->
<?php if (isset($tertiaryNav)) {
echo "<div id='tertiaryNav'>";
echo $tertiaryNav;
echo "</div>";
}
?>
<!-- end tertiary navigation -->
<!-- content with three levels of navigation -->
<?php if (isset($contentThree)) {
echo "<div id='contentThree'>";
echo $contentThree;
echo "</div>";
}
?>
<!-- end content with three levels of navigation -->
</body>
(I have to define ‘primaryNav’, ‘secondaryNav’, ‘tertiaryNav’, ‘contentOne’, ‘contentTwo’ and ‘contentThree’ in separate divs because the menu-columns are ‘position: fixed;’)
Now I tried to use the
$session->redirect($page->child->child->url);
in the products template, but still gives me that blank page, and it still seems to load a page at each step if the path until it gets to the first child. If I have this re-direct enabled and click ‘View’ from the admin, I also get the blank page, so I have a feeling that I’m “sawing over the branch I’m sitting on” somewhere in the chain of templates. I just can’t figure out where I’m going wrong.