[contentbox] Building out the menu

Just a couple of quick questions about building out the menu. I found this nice little snippet to display my menu and it works great with the a few exceptions

    #cb.rootMenu(type="li")#

First I am using ses urls and the links that it builds out are not SES. I end up with links like

/index.cfm/about

Second I have a blog located at /blog. How can I easily add that link into the menu. The blog was built out by content box but isn’t really a page so it doesn’t get included in the menu.

If you wish to add menus to the Admin menu, this is done via code like this.

var menuService = controller.getWireBox().getInstance(“AdminMenuService@cb”);
menuService.addTopMenu(name=‘CronusFramework’, label=“Cronus Framework”, permissions=“SYSTEM_TAB”, href="/cradmin");

I usually add this to the onLoad of the module, so that when it is removed then it is not added to the menus.

This isn’t the admin Andrew… This is just the normal menu bar on the front end of the website.

Sorry Dan, didn’t read it correctly. The index.cfm is added if you have this in your routes.cfm config file.

// Base URL
if( len(getSetting(‘AppMapping’) ) lte 1){
setBaseURL(“http://#cgi.HTTP_HOST##getContextRoot()#/”);
}
else{
setBaseURL(“http://#cgi.HTTP_HOST##getContextRoot()#/#getSetting(‘AppMapping’)#/”);
}

If you do not wish to have the index.cfm, your routes should look like the above.

Thanks Andrew, that fixed one of my issues!

Now what If I want something else in the menu that isn’t a page. Such as a link to /blog or maybe a link to our facebook page (not doing this here but as an example)

What does this actually call?

#cb.rootMenu(type=“li”)#

How can I modify that so I can add a link in there for my blog (/blog) ?

No problem Dan.

At the moment, ContentBox as far as I am aware, still only builds the menu from pages and content. If you need more then you will need to grab the super menu from forgebox or roll your own.

As for what it calls, it is the ContentBox helper which can be found at contentbox->plugins CBHelper.cfc

Thanks for the info Andrew! It didn’t really matter where blog went so I just threw it on the end haha

    #cb.rootMenu(type="li")#
  • Blog

Dan,

For the blog to be added, you can easily do this by tdoing the following. By default the route for the blog is /blog so you can just create an empty page in the root called “Blog”. That’s it. The blog route will take over.

However, if you want really deep control of the menu system you have two choices:

  1. Ask the menu system to give you a type=“data” so it gives you back a structure you can manipulate at your own will
  2. Use the super menu module by Joel Watson, which allows you to build any type of menus you would ever desire.

Joel, do you think maybe we should make supermenu a core thing? Thoughts

I think super menu should be, not the version that Joel wrote. Sorry Joel, as much as I like the idea and what it brings, I think one like what Wordpress offers to be better. I started working on one, but the UI for trees in jQuery sucks.

I agree that a more robust menuing system should be core, and I also agree with Andrew that it should not be Supermenu–at least not in its current form. It was always intended to be a non-core module, and I wanted it to be something like many of the plugins for WordPress that do the same thing without getting too tied up in core Content Box stuff.

So while there are certainly parts of it that could (and should, i think) be reused in a core module, I think a migration of it to core would warrant a fresh look at it so it can be more tightly integrated.

I’m happy to help out however I can. I’ve found the jQuery tree to be pretty simple to work with (and don’t think the UI is bad…im pretty happy with the implementation in SuperMenu as it is), so maybe that’s an area I can contribute.

Thanks!

The idea that I was looking at was something like the attached image.

Basically two trees, one populated with all the available pages and the other the menu structure. The one on the left in this case has a sub context that shows how to add a link, where as dragging the leaf or node from the right to the left will add it that way if coming from the ContentBox pages.

The ability to sort the nodes in the menu, re-arrange and saves it automatically on each change. As well as define menu structures here as well. For example the tree on the left could have three menu structures defined, and then the user programmatically selects the one they want to use.

From here, the menuBuilder would then have a provider, similar to media files, where one can use different provider types to display different menu packages. Which is me thinking out loud, but it would be nice to be able to provide different ways to display the menu, so that the files and handling is kept as a single package.

not being an expert with jQuery, finding a tree that would allow me to do this easily was not an easy search.

cbMenus.PNG