Jump to content

Claus

Members
  • Posts

    82
  • Joined

  • Last visited

Everything posted by Claus

  1. Hi totoff The purpose of the redirect would be to avoid that users would click on ‘Products’ in the first menu-column, and then see a list of products in the second menu-column but without any content. Without a redirect that would look like so when clicking on ‘Products’: Home Apple [EMPTY] *Products Banana News Orange About Contact And then clicking on ‘Apple’ would look like so: Home *Apple Description [EMPTY] *Products Banana Features 1 News Orange Features 2 About Features 3 Contact The user would have to click through the hierarchy of the primary, secondary, and tertiary menu-columns to finally get to see the content: Home *Apple *Description *Description for ‘Apple’… *Products Banana Features 1 News Orange Features 2 About Features 3 Contact This is what I want to avoid by having a click on a menu-item in the primary menu, automatically point to the first-found ultimate page of that given tree.
  2. 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.
  3. Hello everybody! This is my first foray into the world outside Wordpress, and ProcessWire looked like it would be able to do what I want to build without overhead, and at the same time an opportunity to learn. I have no coding skills at all. I am diving head-first into the wall here, so bear that in mind please. I have a few questions on the site I’m working on. I’m using the ‘intermediate edition’ where ‘_main.php’ renders some divs of menus and content conditionally, if the variables are declared in the templates (that are loaded before the _main.php). The home is a column of sub-pages like this: Home Products News About Contact … Under the Products I have several sub-pages with products, which in turn have sub-pages of their own. I’d like to have a click on the Products to automatically link to the first product’s first child-page, so I saw this in another thread: $session->redirect($page->child->url); But when I place it in my Products template, and click on ‘Products’ in the main menu, my browser redirects one level at the time, until it gets to the first child of the first product, but the page is then blank (view source shows that the page is empty). The URL looks correct, and if I turn off the redirect and load the very same URL then the site renderes as expected. So my question is what I’m doing wrong here? Additionally I’d like to ask if there is a way to make a redirect go directly to the first child of the first product-page, instead of going in steps one level at the time? ***** Another question entirely is that I’m using the ‘renderNav’ in ‘_func.php’ to render my menus, and in the sub-menus I get the name of the sub-menu at the top of the menu like this: Products Apples Pears Oranges … How do I remove the ‘Products’ from the top? ***** Thanks! Claus
×
×
  • Create New...