Webjack Posted December 23, 2023 Share Posted December 23, 2023 I'm using a beginners version and am surprised that the children and grandchildren pages are not listed in the drop down menu type menu items. I looked at the code and, as far as I understand, it is implemented for that. <!-- top navigation --> <ul class='topnav' role='navigation'><?php // top navigation consists of homepage and its visible children $homepage = $pages->get('/'); $children = $homepage->children(); // make 'home' the first item in the navigation $children->prepend($homepage); // render an <li> for each top navigation item foreach($children as $child) { if($child->id == $page->rootParent->id) { // this $child page is currently being viewed (or one of it's children/descendents) // so we highlight it as the current page in the navigation echo "<li class='current' aria-current='true'>"; echo "<span class='visually-hidden'>Current page: </span>"; echo "<a href='$child->url'>$child->title</a></li>"; } else { echo "<li><a href='$child->url'>$child->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> I spent the afternoon trying to figure out why it doesn't work for me and thought that somewhere in the administration there's a checkbox to enable this function that I'd inadvertently disabled. What can you tell me about this ? Link to comment Share on other sites More sharing options...
da² Posted December 23, 2023 Share Posted December 23, 2023 24 minutes ago, Webjack said: $homepage->children() This returns only first level children. If you want grandchildren at any level I think you need to create a recursion function. Link to comment Share on other sites More sharing options...
Webjack Posted December 23, 2023 Author Share Posted December 23, 2023 Yes, but I don't have any children displayed. See https://wire.reseauk.info/. As for the recursion function, I'm working on it, but the script I tested earlier modified the Site Map. https://wire.reseauk.info/site-map/ Link to comment Share on other sites More sharing options...
Webjack Posted December 24, 2023 Author Share Posted December 24, 2023 Hello, ? Quote If you want grandchildren at any level, I think you need to create a recursion function. I've solved the problem with my sitemap and am looking to adapt a script for recursion and here I am looking at code and learning PHP (and English) at the same time. I should have started sooner ? Then, while doing my research, I came across some very interesting contributions and was amazed at the possibilities offered by PW. What a job done! I'm delighted to have finally found what I've been looking for for years. A system that allows me to learn while I work, with enough resources at my fingertips to set up a site. The rest is done at the same time, and there's enough to last a lifetime. I've begun to tell the story in an article I started this morning about my adventure with this CMS-CMF. Visitors will be able to follow the day-by-day progress I've made with it. https://wire.reseauk.info/about/ Merry Christmas to all! ? 2 Link to comment Share on other sites More sharing options...
Nicolas Posted December 24, 2023 Share Posted December 24, 2023 Hello Webjack, Great writeup on ProcessWire from a beginner point of view. A quick note : in the breadcrumb ProcessWire is spelled wrongly. It should be ProcessWire whithout a dash (-). Glad to see you're enjoying ProcesWire while dicovering it and learning english at the same time. Merry Christmas !! 1 Link to comment Share on other sites More sharing options...
Webjack Posted December 24, 2023 Author Share Posted December 24, 2023 Quote A quick note : in the breadcrumb ProcessWire is spelled wrongly. It should be ProcessWire whithout a dash (-). No, it's not a mistake. It's because it was written normally but, at some point, while testing something else, I got an error (something rejected) because there was confusion with a title. So I changed the title and forgot to correct it later. ? In fact, it's a test site and I've taken the opportunity to start a few articles to familiarize myself with the system, which I'm learning by doing. It's the same for English. I'm improving. ? 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