Posts Tagged ‘Software’

Superfish Menu Fix for Joomla 1.5

Friday, July 2nd, 2010

So after moving some menu items around on a website, a client calls up noting issues with the ordering of items in the menu. This site is not using the usual mainmenu module from Joomla, but another module called “Superfish Dropdown Menus“. Apparently this is a pretty common issue and only affects people that have moved or removed anything in their menu. So, after much head scratching and trying things out, I finally came up with a fix for the menu ordering issue:

First, add the following functions to the “superfish_modMainMenuHelper” class in the “helper.php” file:

function sortParent($x, $y){
  if($x->parent==$y->parent){
    return 0;
  }else if($x->parent < $y->parent){
    return -1;
  }else{
    return 1;
  }
}

function sortByOrdering($x, $y){
  if($x->ordering==$y->ordering){
     if($x->parent==$y->parent){
        return 0;
     }else if($x->parent < $y->parent){
       return -1;
     }else{
       return 1;
     }
   }else if($x->ordering < $y->ordering){
      if($x->parent==$y->parent){
         return 0;
      }else if($x->parent < $y->parent){
         return -1;
      }else{
        return 1;
      }
   }else{
      return 1;
   }
}

Next, just above the line “$user =& JFactory::getUser();” in the buildXML function, insert the following lines of code:

usort($rows, array("superfish_modMainMenuHelper", "sortParent"));
usort($rows, array("superfish_modMainMenuHelper", "sortByOrdering"));

This will sort the items by what their parent is and then sorts by the ordering, taking into account the ordering of the parent items. After that, the buildXML function will take care of putting the menu together.

A really strange issue and really frustrating fix.

I also make no warranty on the above fixes. I’ll answer questions, but don’t expect me to repair your site for you (backups are your friend).

Descending Explorer

Sunday, November 15th, 2009

Some time ago, I wrote a little PHP script for my home server so I could look at all the images in a folder in the server without having to click on file after file.

I wrote it mostly because my little brother would upload funny images that he found and then ask me if I had seen them yet. Being the lazy programmer I am, put together the following to show thumbnails of the images so I don’t have to click on every single images to find the ones he was talking about (since he could never rememer the file names).

An example can be seen here.

So decided to polish it a little and put it up for people to use. Have fun with it. :D

You can download a copy of  Descending Explorer v2.1.