Tips and Tricks

How to: Language Switcher Menu Item

For many bilingual websites, the standard Language Switcher block that comes with the locale module (shows both language links in one block)  will suffice. However, for Canadian Federal Government sites, the more typical method is to have a menu item in the top nav which shows only the single flip language.

I have come across a few implementations of this all which are implemented in templete.php. Since this is not the correct way to do this (since this is not a theme function) I thought I would document how we do this at LiquidCMS.

Can't clear taxonomy cache in D6 - don't use static vars in D7

Just stumbled upon this core bug today and thought i would post for a couple reasons:

  1. i have written close to 100 D6 modules and somehow managed to never come across this
  2. it is pretty bad.. lol
  3. has been fixed in D7 with a cool new API call

The bottom line is simple:

there is no way in D6 to clear the taxonomy static cache

basically what this ends up meaning is:

Patches to support i18n in D7

We are currently involved in multiple bilingual Drupal 7 projects. As we proceed with development we are coming across numerous i18n related issues. I thought it might be useful to list the various issues/fixes/patches/solutions we are providing all in one spot.

translatable field properties "description" not used when in collection

Admin Role for D7.

A very useful module in D6 days called Admin Role. It attempts to convert the concept of the superuser (uid = 1) to a role; thereby allowing multiple users to be the superuser. Obviously a concept that should be in Drupal core. So much so that in D7 they did included this into core. The downside of this is that they totally screwed up its functionality and despite attempts to get the functionality fixed (Admin role should always provide all permissions (create a superuser role)); no such luck.

Re-add Create Content to Admin Menu

Are you like me? HATE that they decided to remove the Create Content links from the admin_menu module in D7?

ok, here is the code to add it back:

Hide support only node pages

On most projects we have node types created which we have no reason for full page views. Typically these are support node types. If we mix this with the concept that NO page that a user should be able to see should ever have a url like node/456 then it is simple to simply implement the following logic:

If a node page does not have a url alias defined; let's not allow access (unless admin).

This small access override does this:

 

Custom Panel pages shown as Tabs

Quick discovery I made last night.. might save some hair pulling:

In the past I have added tabs using panels (or views) to std node tabs or user tabs… I simply would set their path's to something like node/%node/tab1 or user/$user/tab1

I figured I could do this with completely custom pages as well as long as paths were simliar:

custom/tab1, custom/tab2, etc

It seemed like it should work but it wasn't.

Turns out it sort of was working but there is template.php code required to "enable" tabs for non node/user custom panel pages:

Module Pick of the Week: Tab Tamer

This is a pretty simple module but does exactly what you want on almost every project you will do. Tab Tamer does the following must have tasks:

  • re-order your tabs (primary or secondary tasks)
  • rename any tab (as of version 1.1)
  • hide or disable any tab

That's it; that's all. But it does work so well.

in

Multipage User Registration form

The University of PEI (subcontracted from Dave Kisly) required a complex multipaged user registration form for their CAUBO project. There are a few posts around on creating multipage forms, but most are incorrect, don't apply well to the user registration process or are simply too complex to map to your specific requirements.

We did an initial version of this registration module based on one of these recipe guides but with numerous changes from the client it eventually became a very messy piece of code that was too complex to continue with all the changes required.

Views 6.x-2.x-dev adds Display Cloning

Just a quick note to those followers of our blog - as of around August 13, 2010 the Dev release of Views 2.x now supports cloning a display. Very cool feature and huge time saver so thought i would mention it.

You can read more about it here: http://drupal.org/node/348975 .