drupal

Reset menu sort "weight" in Drupal 6

One of the most amazing and annoying things in Drupal 6 is the menu system. Thanks to a bunch of JavaScript magick, you can drag menu items around to reorder them, create submenus, and so forth. Unfortunately, once you've moved a menu item it no longer alphabetizes itself. If you want things to alphabetize themselves again, you are left with two options:

You can manually alphabetize the menu or submenu every time you change things or add a new menu item, forever and ever and ever. If you're not too keen on that idea, you can edit each of the menu items and reset their weight to 0, which makes them alphabetize again.

Neither option is ideal, so I created a third: this bookmarklet will set the weight of all menu items to 0 in one fell swoop. It also works for resetting block sort order, if you wanted to do that for some reason.

grab the bookmarklet after the jump.

jQuery update in a multisite drupal environment

Like most Drupal hackers, I love to hate jQuery. The primary reason for this is that the version of jQuery included in Drupal core is always several versions behind where it should be. Unfortunately updating it is a serious undertaking, usually reserved for the next Drupal version. To get us by between releases, there's a module called jQuery update. It's pretty rad. It replaces the core jQuery dependencies with a newer jQuery version. It has one caveat though:

The tricky step with this module is that you will need to *replace* the jquery.js file in core with the jquery.js file included in the jquery_update directory...

In Drupal, messing with core files is poor form. Not only does it mess up the upgrade path, it causes all sorts of discontent in a multisite environment. And I spend most of my time in a multisite environment.

my fix for jQuery update in multisite drupal after the jump.

a drupal path redirect bookmarklet

i threw together a fancy little javascript bookmarklet to create redirects in drupal, and figured i'd share:

<a href="javascript:d='example.com/';location.href='http://'+d+'admin/build/path_redirect/new?edit[redirect][redirect]='+encodeURIComponent(location.href.split(/[\?#]/)[0].replace(RegExp('https?://'+d,'ig'),''))+'&edit[redirect][query]='+encodeURIComponent(location.href.indexOf('?')&gt;-1?location.href.split(/[\?#]/)[1]:'')+'&edit[redirect][fragment]='+encodeURIComponent(location.href.indexOf('#')&gt;-1?location.href.split(/#/)[1]:'')+'&edit[path]='+encodeURIComponent(String(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text)).replace(/[^a-zA-Z0-9]+/g,'-').toLowerCase());">new path redirect</a>

for this to work you need the path redirect and prepopulate modules installed... then simply replace "example.com" in the snippet above with your domain name, and save the link as a browser bookmark.

now click on it, and it will add a redirect to the current page. if you select any text before clicking the bookmarklet, it will use that text for the redirect path. this bookmarklet supports both internal (drupal) and external paths. it also works with urls containing queries (?foo=bar) and fragments (#baz). tested in ie, firefox and safari.

have fun!

where does the justin come from?

answers to a few questions from my server logs:

  • where does the justin come from?
    i'm from the southeastern end of washington state, but i currently reside in utah county, utah.
  • is your space cooler?
    yes, my space is cooler than yours.
  • how do i carry a loaded gun?
    i wouldn't suggest carrying it in your pants, unless you want to become another strange google search result

new features! ch-ch-check it!

when i get frustrated or stressed, justin hileman dot info gets upgraded. on that note, my blog has a couple of new features that you prob'ly didn't even notice. most of you won't care, but i'll point 'em out anyway. because i'm a nerd like that.

my space is cooler than your space

if you've visited my myspace profile recently, you've noticed that it doesn't look much like a standard myspace profile. which i'm pretty stoked about, since the hideousness of most myspace profiles approaches obscenity.

one key element in the makeover of my space is the blog. you see, i have way too many blogs already, so i really don't want to post to all of them. and i usually just end up crossposting everything from my regular blog to the myspace blog.

so i replaced it.

drupal dynamically generated MySpace blog replacement

a more secure drupal [multisite] install

I love the Drupal CMS. One of my favorite features of Drupal is the ability to do a multisite install. This site and my other blog, i <3 stella, are hosted on the same box, using the same Drupal install. Several sites can share one codebase. Updates are easily rolled out to every site simultaneously. Overall, it's a wonderful idea. But I have some problems with the implementation...

drupal secure multisite tutorial after the jump.

necessity and innovation

Note: The philosophical musing in this blog post is hidden behind a couple of really nerdy anecdotes. Feel free to skip to the punchline.

A couple of years ago I started writing a CMS. I wasn't happy with any that I had found, and I was convinced that I could do a better job. the first iteration was light and fast, database driven, and extremely customizable. But it still required too much hand coding.

I learned a ton from that attempt, so I decided to give it another go. Version 2.0 would be modular and extensible. I decided to build a module for every feature I wanted but hadn't found in a CMS. I was well on my way to the CMS dreams are made of when my external hard drive bit the big one, leaving me with no backup. Then my laptop was stolen, and my CMS was gone forever. 2.0 never made it to a production server.