Server-side Included contextual menu

thugsb's Avatar

thugsb

22 Jul, 2014 04:28 PM

I'm trying to output a menu on our site. I'd like to use a server-side include (SSI) to do so, so that when a page is added/moved/removed, we don't have to republish the whole site (as we currently do), but can just republish the SSI.

However, I'd also like to have the SSI output "current" classes on the current page and ancestors (the classes themselves don't matter, but they need to be there, and obv it would be good to have a different class for ancestors than for the actual current page).

Do you know of any menu plugin I could use for this? Maybe the SSI can generate a multi-dimensional array, and then each page just adds a 'current' tag to the appropriate element in that array? Or something..?

I don't not want a JS-based solution. Thanks!

  1. 1 Posted by Eric L. Epps on 22 Jul, 2014 05:36 PM

    Eric L. Epps's Avatar

    That is basically what I do. I use an Index Block and have a format that generates PHP code. Instead of building an array, though, I just compare the current page's path with the parent folder (if current page path contains parent folder) to set a current flag (class name). I do some JS after the fact, too, but it works standalone.

  2. 2 Posted by thugsb on 22 Jul, 2014 05:57 PM

    thugsb's Avatar

    Any chance you would attach your format? Thanks!

  3. 3 Posted by Eric L. Epps on 22 Jul, 2014 07:35 PM

    Eric L. Epps's Avatar

    I'll have to clean it up a bit first, but sure.

  4. 4 Posted by Eric L. Epps on 23 Jul, 2014 03:52 PM

    Eric L. Epps's Avatar
  5. 5 Posted by thugsb on 23 Jul, 2014 03:56 PM

    thugsb's Avatar

    Thank you so much, that's fantastic!!!

  6. thugsb closed this discussion on 23 Jul, 2014 03:56 PM.

  7. thugsb re-opened this discussion on 23 Jul, 2014 05:39 PM

  8. Ryan Griffith closed this discussion on 23 Jul, 2014 05:47 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac