Drupal – When to Code and when NOT to….

I have found a really great book for those who want to do Drupal development from O’Reilly.Programmer’s Guide to Drupal. This isn’t really a book for those who want to lhaveearn PHP though. It’s for those who are already comfortable with coding and want to apply those skills to Drupal.

Image

What this book does really well is to show you when to start writing your own code and when not to. It also recommends that a novice Drupal developer learn to build sites in Drupal without any custom coding at all in the beginning. With something like 24,000 modules out there, there is always a good chance that someone has already written code for the very purpose you have. Or that judicious use of core modules will allow you to get where you need to be.

Check this book out: it is AWESOME!

http://shop.oreilly.com/product/0636920027799.do

Advanced CSS Selectors and Drupal

Drupal can be difficult to override at times in terms of styling unless you place your intercepts in a submodule’s PHP so creative CSS knowledge and implementation is a must to keep your site from looking “too Drupaly”.

One CSS technique that I have been using a bit lately that you don’t usually run into in systems where the HTML is more easily customizable is the title attribute selector. Warning – this is really a hack. But I think that it deserves a place in any Drupal Developer’s toolkit.

The title attribute looks like this:

a[title~=Request]{

/*css stuff goes here*/

}

This selector targets hyperlinks (a) that have a title that contains the word Request (case sensitive too). This selector will add whatever you add in the following curly brackets. There are other options too. See the w3s link at the bottom.

Image

The SS is really two SSs: one with the selector disabled so you see the element and one with it turned on. The element that needs to disappear is a link to the /user/password page. For whatever reason (this is Drupal and sometimes it takes so long to figure out the mystery that it becomes a Pyrrhic victory as the deadline is missed) this link will take you to a place where the UX sucks. The workaround is pretty easy though. Use the Password reset form and hide the link using CSS. But since the link has nothing special in its selectors that gets tough. So, use the title attribute selector. The green box in the SS is the form for passwords, BTW.

http://www.w3schools.com/css/css_attribute_selectors.asp

Me Alias Module and replacement pattern for the UID

Now that I can hide menu tabs, I need to be able to recreate what some of them do in the menus that I want them in. And the user edit menu tab is a good example. the path that is listed in the shortcut is /user/%/edit. but this relies on a function to get the uid in place of the %. So you can’t simply make a menu item that points that way. But, I found a great module called Me Aliases that allows you to use tokens in a very easy way. Just install the module and you can use the path alias of me to get the uid of the current user. So you can create a normal menu item that points to /user/me/edit and it will take that user to the edit section of the user’s account. VERY NICE. And easy. No configuration, just installation of the Token module.

http://drupal.org/project/menu_token – this is another module that might provide similar functionality