Jump to content

Menu - Parent container for children pages without an actual parent page?


Maverick
 Share

Recommended Posts

Hey there guys,

Current situation:

The page structure looks like this:

Home

->About

->->Page 1

->->Page 2

->Test

This structure comes back in the navbar menu. I'm using bootstrap as css/js framework.

"About" is the visible container for the dropdown menu of Page 1 and Page 2. I click on About and then I see Page 1 and Page 2 which is great.

What I would like to have is this:

Home

->About

->Page 1

->Page 2

->Test

and still have "About" as the visible container for Page 1 and Page 2 in the navbar so it acts like it's parent (without being an actual parent).

Is there any way in processwire to have such parent page without an actual page?

To get the bootstrap navbar working with the processwire page structure I was following this tutorial http://wiki.processwire.com/index.php/Bootstrap_Navbar

Link to comment
Share on other sites

<ul>
<?php 
foreach($homepage->children as $nav){

  echo "<li>".$nav->title;

  if($nav->numChildren){
    foreach($nav->children as $nav_2){

      echo "<li>".$nav_2->title;

    }
  }
}
?>
</ul>

This should generate a single list of entries, even though pages are nested in the backend. Just change the variables to fit your purposes.

  • Like 1
Link to comment
Share on other sites

Hi there

Thanks LostKobrakai

how should $nav_2 be defined then?

I might have described what I would like to achieve not corrently the first time btw ...

I'm looking for a way to have all url like this: example.com/page1 example.com/page2 etc and still group page1 and page2 into About container in the navbar on the front-end (in a dropdown menu).

In the current situation the urls are like this: example.com/about/page1

Link to comment
Share on other sites

You can use url segments on the homepage to achieve this https://processwire.com/docs/tutorials/how-to-use-url-segments/

Go through it, and tell us if you don't know how you can use them in this case. We'll jump in and explain.

edit: In some way you would be doing a simplified version of what is being discussed here: https://processwire.com/talk/topic/8894-how-to-implement-the-url-like-wordpress/

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...