Feeds

Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Aug 24 2011
Aug 24

Day two of Drupalcon London and it was definitely 'the morning after the night before' for a lot of people at Fairfield Halls in Croydon. Things were much calmer and the initial volume levels from the assembled masses more muted than on the opening day as many people nursed some sore heads. Nevertheless the main hall was packed by just after 9am in time for the days keynote from Tom Standage, Digital Editor from The Economist magazine. I wasn't too sure prior to the keynote what form his talk was going to take, but it proved to be extremely entertaining and completely different from anything else that is likely to be heard all week (or probably at any other Drupalcon for years to come for that matter).

Tom explained how the origins of social media went as far back as the ancient of Ancient Greece and illustrated many examples from throughout the ages of how the original media was social media and had been like that in one form or another for hundreds and thousands of years until the year 1883 when the New York Sun newspaper was founded. This was the first newspaper to use an advertisers funded model rather than subscriber/reader fee based model for a publication and changed the face of how media was produced and consumed. It went from being a two way exchange to a one way street, with a limited number of people (the editors) deciding what information was important for the readers to receive. The current form of social media on the Internet has reverted media and communication back to being a two way exchange, but Tom expertly led us from start to end of the history lesson in a very entertaining fashion. If the speech has been recorded and is viewable on the Drupalcon London website, I thoroughly recommend watching the whole thing, it is informative and entertaining in equal measures.

For the first more serious seminar of the day I decided to attend the one on Deployments and the features module. Features is something I first came across back at the Drupal London meet at Microsoft earlier in 2011 and wasn't really convinced about it. I've since seen the power of features bur still never had the chance to play with it firsthand. The seminar was informative covering topics like what should be in features as opposed to install profiles, use of drush make and how features are both upgradable and revertable. It went into a little too much detail from a novices perspective at times but it was a useful session overall.

After lunch (which I again skipped, 0 for 2 at eating at Drupalcon, aside from a can of Pepsi) I headed back to the main hall along with my colleagues from The Collinson Group (shameless plug) for a seminar on one of the most important topics for large Drupal websites, making Drupal perform 'like a rockstar' (I must point out at this juncture that I really don't like the term rockstar for any kind of web development stuff, leave it for musicians, anyway I digress).

Four main reasons were outlined for the slow performance of Drupal websites during this seminar, and they are listed below:

  1. Full page renders - 200 to 300 SQL queries per page?
  2. Dynamic content to anonymous users
  3. Excessive/slow/non-optimised DB queries
  4. Naughty modules

All of these were valid basic points, coupled with the fact that many drupal sites don't use any forms of caching, not even the caching built into Drupal by default! Different methods of caching such as Drupal's default caching, memcache and APC were discussed throughout the talk along with the benefits that each type of caching can provide. The use of performance measuring tools for page loading such as the devel module and something called New Relic (which I am not currently familar with but have seen it being advertised at this Drupalcon and I am very keen to try it out) was advocated as they will allow developers to work out where their load time bottlenecks are occuring (e.g. whether its the SQL (which is a common cause), the strain on the server from the traffic, or other reasons).

Another key aspect of Drupal performance that was highlighted is your sites MySQL configuration (if that is your DB of choice). Several settings were picked out as being key settings, though obviously not the only ones:

  • key_buffer_size
  • query_cache_size
  • query_cache_limit
  • table_cache
  • sort_buffer_size
  • myisam_sort_buffer_size
  • tmp_table_size

The values of these need to be adjusted depending on the server hardware at ones disposal. It was also recommended that if you are using caching to check the cache expiry to see whether its renewing too often, and other good tips such as is path alias caching and whether your home page should always be cached, even if it has dynamic content on it (with a period refresh, how frequent depending on likelyhood of updates). Again this is a presentation where I would definitely recommend getting hold of the slides.

This was shortly followed by Robert Douglass (@robertDouglass) leading a very interesting session on the current state of Drupal in regards to apps and marketplaces for those Apps. This week Acquia (for whom Robert works) have announced their intention to have an app marketplace, initally for their subscribers and are hoping to make that public by the end of 2011. What I was not aware of is that two other companies - Subhub and Phase2 (who were both represented well during the session) have already launched App markets in the last year. Of the services to be initially offered on the Acquia marketplace, the one that really interested me was Visual Website Optimiser (or VWO for short) as we made very good use of this at WikiJob during my time there and its a fantastic SAAS offering, so that should be watched very closely for anyone with an interest in conversion rates and analytics.

The main piece of news to come out of this informative session apart from the discovery of the existing Drupal app marketplaces was that the three companies (Acquia, Phase2 and Subhub) are working together on an Open App Standard (OAS) so that developers only have to work to one set of specifications when building their apps but the apps would be able to be on many app stores (if they met the app store's individual business criteria), at least from the coding perspective. I think this is great for many reasons, not least of all they have seen the issues that have arisen with some of the mobile app development (android in particular) and are doing their best to make sure there are not the same issues with any Apps for Drupal.

Anyone wanting more information about the Open App Standard initiative, you can read about it at http://groups.drupal.org/open-app-standard/oas.

Finally for the middle day of Drupalcon the last session I attended was entitled 'A bulletproof plan for themeing' from the very good Rasmus Kalms (@kalms) from Copenhagen. He spoke a lot of common sense including how style guides can be very good tools to make use of and how they can prevent the need for designers to design every element of every page allowing the themers to use their brains, so long as they know what the basic page elements such as form elements, lists, content boxes, typography and images are supposed to look like. He also advocated close communication between designers, developers and project managers along with code review between front and back end developers. All things that may sound like common sense to some people but I'm sure its also something that a lot of people out there are not doing enough of (or at all in some cases).

Another sensible recommendation was for themers to organise their themes. Inside your main theme folder, to have subfolders for each type of template e.g. views, panels and nodes to name but three possibilities. We were also encouraged to take the plunge with HTML5 and CSS3, and to use things like CSS pre-processors which allow the use of such CSS3 functionality as variables, mixins (which look amazing), nested css and even basic functions. If anyone reading doesn't know what a mixin is, below is a basic example (I may not have the syntax 100% right but you get the idea):

.myclass {
   color: red;
}

.mydivclass {
   .myclass; 
}

Two drupal projects to look at in terms of preprocessors are Sass and Less (drupal.org/project/sass (or less)). I haven't investigated these myself yet but will be doing so shortly.

Overall, another great day at Drupalcon. I hope those who went to Batman enjoyed themselves, stay tuned for the final instalment tomorrow night.

Feb 09 2011
Feb 09

Last night, myself and a colleague on my current contract assignment went to the February Drupal Drop-in from the Drupal London community, held at Microsoft's very swanky offices near Victoria Tube station. The theme of the evening was useful modules that maybe not everyone would be aware of, so there were not going to be any talks on CCK and Views and "standard" modules such as those.

What followed were a wide range of presentations and copious amounts of free Domino's pizza (again, thanks to Robert Castelo (sorry for the mix up!) and the nice people at Code Positive for shelling out to feed a large group of us and there was some really good information to be had, as well as great contacts to be made, though having done a long day at the office I was at my unsocialable best. I'll try to be more friendly and actually talk to people next time!

After an initial mini sales pitch from Microsoft about their new platform Microsoft Web Matrix, designed to be their answer to Xampp for local development, combined with a means of trying to sell hosting to people, the Drupal module sessions got underway. I summarised a lot of the points for the team on my contract assignment, so thought I would also share these notes with the wider community. There were some very good modules mentioned, some I had prior experience of, some I knew of but never had used, and some I'd never heard of! Please keep reading for details:

Flag Module + Flag Weight Module: Flag module can be used to "flag" things (nodes, users, comments) in order to create lists of whatever is flagged. You can have different levels of granularity (e.g. one global flag list, or a list per user). Flag Weight module allows for the ordering of these lists. This could be used to create anything from an Amazon wish list to an internal favourite content / bookmark list.

This also combined with the "Draggable Views" module, which will allow you to re-order your flagged lists by drag and drop, which is rather nice. I can see a lot of potential uses for this module and I hadn't heard of it before so I am definitely going to make use of this in the future.

If anyone wants to check out the slides then please see http://bit.ly/flag-slides for the full presentation.

Panels Module: For those who are not familiar with Panels, Panels is a dynamic form of laying out the content section of pages in Drupal. You can use different panel layouts for different contexts, e.g. when a user is logged in or logged out, or one layout per content type (or combinations, you can have endless panel variants, though having too many would be difficult to manage).

I used Panels extensively on my last job at www.wikijob.co.uk and found it to be incredibly useful. There are various modules such as Panels everywhere and Panelator for extending Panels but I have not used these yet. If you require a website with a lot of different content layouts then panels is a great flexible alternative to using a lot of template files.

Masquerade Module: Simply, impersonate another user when logged on as admin or someone who has "masquerade" permissions. Good for checking out users with different roles or different sets of permissions. I don't have first hand experience of this yet but will be definitely putting it to good use.

Content Management Filter (CMF): Aptly described in the presentation as the "Admin content screen on steroids", the standard admin content screen is, let's face, pretty crap for lack of a better technical term. This module adds far more robust functionality such as searching for content by date, author, title rather than just by content type or published/unpublished.

I've been so annoyed with the admin content screens many times and I've considered writing something like this myself, it just appears someone kindly beat me to it. Another one I will definitely be using!

Backup / Migrate: Automatically create Database back-ups. It stores the backup in the files directory so we would have to be careful about file and folder permissions or risk exposing the DB to the wide world (I'm sure this is all configurable to stop this from happening). I want to investigate this module a bit more before using it but it handles a very necessary task without the need to delve into your hosting or get your system admin's help.

Apache SOLR & SOLR Suite of Modules: Again, for those not familiar, SOLR is another form of Search. It requires a Java based server (Tomcat?) to be set up with the apache solr module installed. SOLR offers all sorts of search functionality not provided by the core Drupal search such as content weighting, "did you mean" on mis-spelt search terms and can do related content for your site (see Dries's blog at buytaert.net for an example).

SOLR and it's associated modules are very awesome, we were running this on the WikiJob site. You can also get the Acquia SOLR module and pay for them to handle your SOLR search if you don't have the capacity to have a Java Server yourself. According to the presentation last night costs start at something like $350 per year - please see Acquia.com for further details.

Module Filter: Provides an Ajax filtering form for the modules screen, useful when you have a billion modules. I would imagine there are quite a lot of production websites out there with an awful lot of modules on their modules screen whether they are installed or not and this just allows for nice, quick filtering. A useful niche tool module.

Context: Allows you to display blocks or breadcrumbs depending on whether certain conditions are met (e.g. you are on a certain page, user has a certain role, combinations of these conditions). It also allows you to do things like display different themes based on conditions. I'm sure it has many other powers too. This is a module I've been aware of for a long time but I've previously been in the panels camp on the long side of the panels vs context argument. Having seen this, I'm probably now part of the argument that each one is better in different circumstances, and I'd like to get more familar with panels.

There were several other modules discussed, including a really nice demonstration of the power of the Amazon.com API and the 960 gridder module which looks like a great tool if you design your websites to the 960 framework or use 960 layouts, but the ones I covered in details were the ones where I took the most notes.

Unfortunately, most of the sites on my current contract are Drupal 5 sites, so at least in the day job I can't take advantage of most of this information and these great modules. I am hopeful that all this module info will add weight to the case of getting everything upgraded to Drupal 6 and possibly beyond!

Hopefully this information proves useful to some people and I look forward to seeing people at more Drupal drop-in's in the future!

Just as a footnote, thanks to @manarth and @ncameron amongst others for some great presentations at the drop-in, keep it up everyone!

Feb 09 2011
Feb 09

As we move into 2011, I have been doing a lot of work with comments in Drupal lately (Drupal 6 to be specific). One thing I have always wanted to know how to do, but never got round to investigating until recently, was the ability to customise the "Post new comment" tagline at the top of the comment form.

Anyone with a passing familarity of the inner working of Drupal would assume that you need to use a "_form_alter" (or Form Alter in English) hook to modify this piece of text on the form. That was certainly my first assumption, and funnily enough, it proved to be incorrect. I spent a fair bit of time with my head stuck in XDebug in Eclipse (the FiveRDesign IDE of choice, for lack of a better option) following the different steps through and changing different variables but nothing would affect the title.

After much digging around Drupal.org unsuccessfully for help on this matter I stumbled across a post which thankfully gave the simple answer (I unfortunately can't find the original post now to give them credit). What is required to override the comment form's title is actually a preprocess function, specifically, preprocess_box. Boxes are one layer of the Drupal theme API I haven't touched before so I was a little bit surprised about this.

All that is required is the following code:

function module_name_theme() {
	return array(
    	    'preprocess_box' => array(
      		'arguments' => array('vars' => array(), 'hook' => NULL),
    	    )
	);
}

function module_name_preprocess_box(&$vars, $hook) {
	switch ($vars['title']) {
		case 'Post new comment':
			$vars['title'] = 'Your new title';
		break;
	}
}

And hey presto, a customised comment form title. This could probably also be achieved with a custom template or overriding the theme function for the comment form if you wanted to take the forms customisation further, but if you just want to alter the title, knock up a quick custom module with this hook in it (and with a _theme hook to register your theme_preprocess_box function) and your comment form will have a custom title in no time.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web