Sub-SubMenu for Blogger with Artisteer, part 1
Currently, we can get only one level of submenu with the standard templates for Blogger created with Artisteer, version 2.3; Hopefully, the possibility of having second and third levels (sub-subMenu and sub-sub-subMenu) will be made in a future release of Artisteer but now, we are reduced to the obligation of doing the required modifications to the template ourselves if we want those. This is the object of this article and it can be made pretty well as you can see from the following figure illustrating an example of sub-menus expanding on three levels:
This article is divided into three parts. The first part shows how to modify the JavaScript code in the template for getting second and third levels of sub-menus. The second part deals with more advanced changes to the code for making our job easier when we have to create very long menus, having tens or even hundred of sub-options; something that is not easy to manage with the standard interface of Blogger for editing the menu. Finally, the third party shows how to style the submenus so that their width is related to their content in in order to have a more pleasing look to the eye.
Note that even if you're not interested in the menu interface for Blogger created by Artisteer; some of the techniques discussed in this three parts article could still be interesting for you to read.
Before we can make the changes seen in this article, we must first be able to know how to make modifications to the template once it has been installed (or published) on Blogger. To do this, you must use the "Edit HTML" tab of the "Layout" option that you'll find in the settings of your blog from your Blogger's Dashboard. Most of this has already been discussed many times on the various blogs about customizing Blogger so I won't repeat the process here but if you need to have some references, you can start with "Can I edit the HTML of my blog's layout? - Blogger Help" and "Layout Guide - Blogger Help".
When someone wants to change the Blogger template code to include several levels of submenus, the first thing to think would probably be to simply edit the template code in order to include the various submenus in ordinary (without any javascript) HTML code; like we must already do for the standard HTML templates produced by Artisteer. For a quick reference on this standard procedure, see Artisteer Add-ons - Cheat Sheet: Part 3 - Navigation. Unfortunately, it's not easy to do the same thing on Blogger because the required code to edit is included in a not easily editable widget; as you can see from the following extract (notice that in order to see this piece of code on your own template, you must check the option "Expand Widget Templates"; as it's also shown below in the upper right par of the figure) :
Also, writing and editing the long list of the required <ul> and <li> tags necessary to express the CSS menu of Artisteer is not an easy task and is very prone to errors; especially when the number of options reach many tens. In my opinion, the method that we'll see in this article is a better solution but of course, you must not forget about the possibility of simply adding your own custom HTML code; especially if you have it already ready at your hand.
From the code illustrated in the previous figure, we can see that once the list of options for the menu has been inserted into the dynamic array "menuitems", the function artDisplayTopMenu() is called. This is the function that will generates the HTML code required for displying the menu using the information provided in the passed array "menuitems" and evidently, is also the one that we must modify in order to allow for the display of second and third level of sub-menus. You can find this function by searching for "artDisplayTopMenu" or simply for "artD" (use [Ctrl]+F to access the Find box) but for your convenience, I reproduce the original source code here :
The first thing we notice is that all the four characters "<> & have been escaped (translated) into their equivalent HTML entities; which makes reading or changing the JavaScript code more difficult. A Blogger template is stored as a XML document; which means that these four characters must be obligatory be escaped. However, instead of escaping them individually, we could also chose to use the global XML escape sequence <![CDATA[ ... ]]>. As this special sequence must be used in a piece of JavaScript code, it must itself be escaped from the view of the JavaScript parser by using either // or /* ... */; which at the final gives us:
// <![CDATA[
... javascript code containing the following caracters: " < > &
// ]]>
By using this special sequence, we can rewrite the code of the function in a much cleaner and lisible way:
Note that the escaping sequence <![CDATA [ ... ]]> can be used for other purposes, such as for fast encoding of javascript ads (AdSense, AdBrite, Amazon, etc.., see the article "Simple and fast encoding of javascript ads (AdSense and others) for Blogger") or for inserting the XML statement <? IMPORT>, as discussed in another article on the use of MathML with Blogger.
To create a sub-menu in Blogger using this function, we must place an hyphen ("-" or dash) at the beginning of the name of each sub-item of the menu's "Link List" configu/ation window:
The new version that I made uses something similar: the second level requires a "-+" at the beginning of each option's name and the third level a "-+="; as you can see in the below figure. I've chosen these labels because they were making the code and the hierarchy of the menu easier to read and understand but of course, you could use anything else; provided that you adapt the code of the function.
And now, without any further delay, here's the revised version of the function artDisplayTopMenu() :
You can see and test the final result by going at the following blog that I've setup for testing purpose: Sub-SubMenu for Blogger with Artisteer.
This concludes Part 1 of this article. In parts 2 and 3, we will elaborate on this feature by first replacing the need to use the dialog window "Link List" in order to manage the menu's options menu (replacing this dialog window is very useful because it's far from beeing to be the best in the world to use when you have dozens of options to adjust) and second, we will see in the last part how to adjust the widths of the boxes in order to adapt them to their content.
A final word of caution: this is custom modification to the template, so if you republish your template from Artisteer, you'll have to remake this modification to your template again.
Welcome!
Thanks for your patience!
S. L.
Labels
- Artisteer (5)
- Blogger (6)
- Followers gadget (1)
- Google Friend Connect (1)
- Joomla (1)
- Picasa (1)
- Windows Live Writer (2)
About Me
- Sylvain Lafontaine
- Consultant - Travailleur autonome pour les bases de données et l'internet.
Donate ($CAD)
If you have liked this site or if I've been helpful, you can support my work by making a donation. Thanks.
Disclaimer • Privacy policy
The information on this blog is provided for informational purposes only. The writer is not responsible for any damage caused by performing actions specified on this blog, or by relying on information published on this blog. By using information or components provided on this blog you are accepting these terms.
This blog uses cookies. You can find information about these and about the privacy policy of this blog by clicking here.

2 comments:
I have a artisteer 2.3 theme loaded onto blogger and everything is great except I cant seem to find coding to establish a wide column above my (right side) 2 sidebars
Necesito ayuda con mi plantilla realize todos las pasos que explico pero me dice que hay un error. Gracias por su ayuda.
Post a Comment