Thursday, December 09, 2010

Drupal baby

I'm probably going to be posting a fair bit about drupal for the forseeable future as I am porting my new company's website over to it.
Drupal is a Content Management System (CMS) which allows you to do just that, manage all your website content in an easy way. It is written in PHP and has been designed to be extremely expandable - as outlined by the number of add-on modules that can be plugged into it.
Many years ago I worked on replacing an aging Intranet system with Plone, a Python based CMS which was quite advanced at the time. I can see lots of similarities between the two CMS systems and this will help as time goes by.

First up to note with Drupal is the module Custom Breadcrumbs.
Breadcrumbs on a website are the little categorised navigation links that you usually see somewhere at the top of the page. They basically form a breadcrumb from your starting location on the website, into where the actual useful content is located.
One of my major requirements in the current project is to have a breadcrumb navigation path that mirrors the actual url used. So for example the address I have is 'mysite.com/category/subcategory/posting'. I want to be able to map the breadcrumb to show 'Home -> Category -> Subcategory -> Posting'. This is entirely possible with Custom Breadcrumbs until you start playing with Views. As per the Views module page description: The Views module provides a flexible method for Drupal site designers to control how lists and tables of content are presented.

The current development version of Custom Breadcrumbs has some support for working with Views but this does not appear to be very easy to understand or implement in ways that you might expect.

I have been through various ways of mapping the breadcrumb to the url categories but in the end plumped for a little way which invloves rewriting the breadcrumb content when looking at certain types of views. See http://www.danielhanold.com/story/views-breadcrumbs-using-arguments for a better rundown.

Another issue that cropped up when using Views is when you have multiple Views on a page and both are using pagination (showing 'next' and 'back' if there are more items than can be displayed on the page). As a default each view will pick up when 'Next' is clicked and all of the views will move to the next page. Not ideal.
Hidden inside each View that you have created will be the 'Use pager' option in the Basic settings. This turns on and off whether the View will paginate or not but when setting it you need to be aware of an option called 'Pager element'. This defaults to 0 and is picked up by all Views on the current page. To make sure that only individual Views move through their own pagers on one page you need to give them a unique number. Doing this will mean that each paginates as expected.

Si