Tag Archives: menus

ddsmoothmenu arrow dynamic paths

Working with ddsmoothmenu Smooth Navigation Menu by Dynamic Drive for a WordPress project I encountered a stupid lack of setting to provide image paths dynamically. This is a jQuery-based dropdown menu which seems and works fine but requires a static path to the images. Only two images though, for the arrows down and right, but it would be a serious issue when releasing a website or migrating to a new server.

So I decided to add a new setting configurable through the JavaScript call in your call-menu file where you could use php/java/python/whateva to retrieve the correct path dynamically and just pass it. I'm using v.1.5 and I did 2 corrections:

  1. in the ddsmoothmenu.js file replaced all smoothmenu.arrowimages strings with setting.arrowimages (just changing 'smoothmenu' to 'setting' in these three lines). There are 5 strings to be replaced at lines 75 to 77. What I do is add a new setting for them in the next section.
  2. Adding the paths to the images as a setting. So at the end my call includes the dynamic path to be used in the menus. Since I'm using WordPress, here there is my code for calling the menu:
  1.  
  2. ddsmoothmenu.init({
  3. mainmenuid: "header_top_menu",
  4. orientation: 'h',
  5. classname: 'ddsmoothmenu',
  6. arrowimages: {down:['downarrowclass', '<?php bloginfo("template_url"); ?>/img/down.gif', 23], right:['rightarrowclass', '<?php bloginfo("template_url"); ?>/img/right.gif']},
  7. contentsource: "markup"
  8. });
  9.  
del.icio.us Digg DZone Facebook Google Google Reader Magnolia reddit SlashDot Technorati ReadMe.ru Dobavi.com Dao.bg Lubimi.com Ping.bg Pipe.bg Svejo.net Web-bg.com