Jump to content

Place holder in menu


Joss
 Share

Recommended Posts

Hi

Is there anyway of generating a placeholder in the page hierarchy? Or do I have to create a blank page?

My particular reason is to do with Bootstrap - with the bootstrap navigation, top level parent items that have children will not link to a page.

When you hard code, you would normally just put <a href="#">item name</a> which you need to trigger the drop down.

However, in the Page structure that creates the menu in Processwire, everything is a page ... or am I missing something?

All the best

Joss

Link to comment
Share on other sites

Hi Diogo

I don't like hardcoding anything in a menu, except perhaps the home button, since that makes site updates difficult.

With Bootstrap, I can create a page with nothing in it and use that as a place holder, but seems a touch overkill! :)

Joss

Link to comment
Share on other sites

A page is more like a abstract node so it can be virtually anything it may or may not have children. This allows for some great flexibility if you use it to your advantage and maybe use a checkbox or a distinct template to use that in you code to generate the menu.

In PW you would simply create a folder and use that as a container for your pages and output it differently. Create a template "folder" and only have the default title field. Use that to create those pages.

In your code you can do a check like this pseudo code when outputing a link

if($child$child->template = 'folder') {
 echo "<a class='dropdown-toggle'>$child->title</a>";
 // .... loop children code
} else {
 echo "<a href='$child->url' data-target='$child->url'>$child->title</a>";
}
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...