Simon Love Posted January 31, 2018 Share Posted January 31, 2018 Hi I've tried Ryan's Hello Worlds tutorial several times and I've just tried it again - This time I started with a blank template out of curiosity. Subsequently, there is now no navigation on any of the pages. Is there a module or whatever which adds navigation? Do I build my own? What's most commonly used approach here? Any help greatly appreciated. Simon Link to comment Share on other sites More sharing options...
rick Posted February 1, 2018 Share Posted February 1, 2018 Hi @Monty, and welcome to the forum! With the blank profile, you are left to build everything you may need for your site. However, you can use the code from other profiles, such as from the site-default/templates/_main.php file to generate your menu navigation, like so: //place this code in your template where you want the menu displayed. <ul class='topnav' role='navigation'><?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' aria-current='true'><span class='visually-hidden'>Current page: </span>"; } else { echo "<li>"; } echo "<a href='$item->url'>$item->title</a></li>"; } ?></ul> Another option could be to use the _func.php file located in the site-default/templates folder of the processwire zip file you downloaded. This file contains a similar function to generate a navigation menu which you can call from a template. It all depends on which method (eg, Delayed Output) you are using to create your site and the structure of your pages, so this is only a general information. Is this the planets tutorial? Feel free to post your structure and someone will be able to give you more specific suggestions. 2 1 Link to comment Share on other sites More sharing options...
Juergen Posted February 1, 2018 Share Posted February 1, 2018 If you want a navigation different from the page tree you can write it also in HTML and add it to the template. Theres no need to use a function to create it. You can get the URL for a page in this way: $url = $pages->get(Id of the page)->url; fe. if the page has the id 45 you get the url like this: $url = $pages->get(45)->url; You can use it to write the menu in HTML and add the URLs with PHP like this <a href="<?php $pages->get(45)->url;?>"><?php $pages->get(45)->title;?></a> This outputs the link and as linktext the title of the page. There are many ways to create a navigation. I recommend you to take a look at the cheatsheet. 2 1 Link to comment Share on other sites More sharing options...
SamC Posted February 1, 2018 Share Posted February 1, 2018 @Monty this might help: https://www.pwtuts.com/processwire-tutorials/creating-a-main-menu-and-sub-menu-for-your-website/ 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