Brandon Durham
Brandon Durham

Reputation: 7727

Hide segment in URL but give code access to hidden segment

I'm using Structure and have a "Supernav" page with multiple children that will make up the supernav for the site. I thought this would be a nice way to have all pages on the site accessible to the client via one location: the Structure UI.

enter image description here

If you visit any of the child pages in the "supernav" group the URL comes out like this:

http://website.com/supernav/prospective-students

I'd love to be able to remove the supernav segment of those URLs so that it ends up being:

http://website.com/prospective-students

I don't even want the supernav segment to appear in the status bar when you hover over these links on the page. Is this possible? With CodeIgniter this comes down to a simple routing rule, but I don't know if that's an option with EE.

Appreciate any help I can get!

Upvotes: 1

Views: 923

Answers (2)

Natetronn
Natetronn

Reputation: 466

You could use Freebie for this as well.

Take control of your URLs — define segments that you want EE to ignore completely. Use 'freebie' segments to trigger template behavior, build dynamic archives inside Structure, or just build special URLs for analytics purposes. Freebie allows you to use segments in powerful, flexible ways without the hassle of dealing with strict URL parsing (like Structure's).

You just add supernav to the Freebie settings (under Freebie segments) and supernav can then be ignored. If you still need to run a conditional off of supernav, {segment_1}, you can use {freebie_1} instead. Read more about that in the add-ons documentation over at Devot:ee and in this post by it's creator.

With that said, I'm not positive if you can output the nav using normal Structure tags and get it to display all children of supernav without supernav itself still being in the URL. To get around this you would need to hard code your navigation (or use NavEE or Taxonomy.)

I hope someone can verify if Structure has a tag/param, or not, which addresses this issue as I'm not really sure either way.

Upvotes: 0

This may be a bit after the fact, but have you considered using NavEE for this sort of situation and replacing Structure wholesale? You can build multiple navigation content, and don't have to "hide" the content. I love Structure, but you would have to use .htaccess in order to get the results you're wanting, as well as some routing stash/embeds.

Upvotes: 2

Related Questions