Drupal

Logo: 

Altering Views Embed Programatically

Views have a tendency to get a bit.. complex. Reusing existing portions of a view makes perfect sense, and the built in tools do a pretty bang up job of letting you create slightly adjusted displays that inherit the pieces you need for the most part. But, somethings crafting more and more displays, just to tweak one setting or another is just beyond frustrating due to pure volume. So instead, I submit the following idea. Start simple, and evolve as needed.

Tags: 

Adding Flexibility to Drupal Views Exposed Location Postal Codes

A client of mine has recently requested that users of their site be able to search their Canadian postal codes more freely. A quick look over the zip codes for Canada shows some interesting variations used by public. The proper postal code could be 'A1W 3A1', but we'll get searches for the variations like these:

-a1w 3a1
-A1W-3A1
-A1W3A1

Ajax Drupal Submenus

Our Seo department asked us to prevent the submenu items for the site's primary navigation from loading initially again, it had to be iframed or ajaxed in post load. I wanted a more standard solution to the issue, something I could safely reuse on multiple Drupal sites.

Solution:
I used our custom module for the site to output a new block 'Custom Main Menu' that I used to replace the default main menu. It added a small dependency to menu_block, but that's an awesome module anyway, and I'm happy to rely on it. The new main menu loads as normal for users that are logged in. For anonymous users, it loads the first level of the main menu, then request ajax requests the rest after page load, replacing the entire menu block with the full menu again to avoid flashing or complex replacements.

Build menu using Menu_Block directly

I run across the need for some very specific menus built on the fly for Drupal once in a while. Things that really aren't blocks that should be running around the block admin. A great example would be ajax calls to obtain the submenus for an item and add them to the page post render for seo purposes.

If you need to access a very custom part of some menu, use the menu_block module, and tweak the following code to your needs:

Tags: 

Pages

Subscribe to RSS - Drupal