Archive for the ‘Content Management Systems’ Category

Drupal at Whitehouse.gov

Emira Mears | Friday, October 30th, 2009

There’s a great piece on the Drupal and the current White House website in today’s New York Times. Worth a read for Drupal users/fans or Open Source keeners.

Contribute to the Community? Yes You Can!

Colin Calnan | Thursday, October 22nd, 2009

I’d been a little skeptical about the idea that anyone can contribute to the Open Source community by giving a little help now and again. This skepticism came from the flaming given for asking ‘newbie’ questions, asking a question in the wrong room or from suffering the raging ego of a well seasoned and highly adored contributor. Today however, I feel much more positive about my ability to give back to Drupal and the Open Source community, and it all came from a simple (or maybe not so simple) thank you. Here’s the story:

Yesterday afternoon, while tearing my hair out over some tricky views problem that I could not find a solution to, I logged in to IRC, which I don’t usually do, to see if I could get some help.

In the #drupal room I asked my question and as usual didn’t receive any replies (which is why I don’t usually log in). It’s a bit of a difficult VIEWS problem and those usually don’t get answered quickly in IRC. While waiting for a response I noticed a question that was similar to mine but not as complex. I took some time (2 minutes) to review the code and I was able to speculate on what the problem was. I posted a proposed solution and it worked. I didn’t really think much of it until later on when I received an email via drupal.org from the person I helped asking me for my e-mail address. I sent it on and this morning I awoke to the email below. Until now I had been wary of devoting my time to hanging around in the IRC channels. This experience has changed my feelings on this quite a bit and I hope to spend a little more of my time in there, when I have it, helping others. In this case, it definitely did pay to help others, but the thank you email was more than enough, it made my day, my week, my month and maybe even my year :) Here’s to contributing more to the community. It doesn’t take much, and just a simple thank you for the help, when given, makes all the difference.

Hi Colin,

Thanks. I am in Fort Smith, NT just on the Alberta/NWT border directly north of Edmonton.
I am a Fire Scientist, I model Wildfire on the landscape. Yesterday I was completing the Drupal Integration part of a multi-year government project, most of us running on little or no sleep and less patience. I CVS updated VIEWS and it became way more strict about the PHP code and broke my drupal. I had been begging for assistance in different irc drupal chats for about 45 mintues when you came along. It really was like saving our team, when the view worked, the entire fire science team cheered. We just wanted to say a real heartfelt thanks.
I am sending you, $20 via email, its a small gesture, as our team knows that $20 will buy a friday case of beer anywhere in canada except north of Norman Wells NWT ;-) Perhaps you can claim to be the first in your office to have been mailed a case of beer by the drupal community – LOL

The Big Reveal: Recent Launches at Raised Eyebrow

Lauren Bacon | Tuesday, October 6th, 2009

The past few weeks have been quiet here on our blog, and as often happens, that silence has been an indicator of just how busy things have been here at Raised Eyebrow headquarters. We’ve been putting the final touches on some exciting new websites that we’re very proud to share with the world. Two major redesigns have just launched – one for a wonderful nonprofit group here in British Columbia and the other for a foundation that’s changing the face of lung cancer research across the United States.

Deaf Children's Society of BC - home pageThe Deaf Children’s Society of BC offers programs, support and resources for families of young children with hearing challenges that range from parent groups for new parents of deaf or hard of hearing infants, preschool and summer programs for young kids, to a library and bookstore where families can access print resources. Their small staff includes several speech-language pathologists and sign language instructors, and they came to us looking to extend the reach of the services they are able to offer through the web. We helped them extend their resources online through the use of instructional videos for new parents to learn sign language that can then be used with their children as they develop language and reading skills.

The new website is a clean but cheerful home for their fun, informative, instructional videos as well as detailed information about the society’s programs and services. Parents can learn sign language in child-sized portions – with signs grouped in themes like animals, colours, numbers, and of course the alphabet, which they can then use to help their young children with developing language skills.

Uniting Against Lung Cancer home pageUniting Against Lung Cancer is a nonprofit foundation that formed in 2001 as Joan’s Legacy, in honour of 47 year-old New Yorker Joan Scarangello McNeive, who never smoked, but died after a valiant battle with lung cancer. Her family and friends rallied and established the foundation to fund research and raise awareness about the disease; over the years it has attracted partnerships with other family foundations, and now Uniting Against Lung Cancer serves as a connector for groups across the United States who are raising awareness and funds. To date, the foundation and its partners have awarded over $6 million in direct research grants in 20 different states.

We worked with Uniting’s staff and board to develop and implement a transition strategy for their online presence, as they re-branded from Joan’s Legacy to Uniting Against Lung Cancer. The new website better reflects the scope and reach of the foundation’s work, and showcases their mission, partners, and events in a design that evokes a deep breath of fresh air on a sunny day.

On a technical note: Both sites run on Drupal’s open-source CMS platform, which gives them a strong foundation on which to develop future site enhancements – something that’s increasingly top-of-mind for our clients. We’re finding that more of our clients are looking at an iterative approach to making site adjustments, and even after a major redesign such as these ones, there are often “wish list” items that we can add to a site over time. We find Drupal provides a robust framework that allows this iterative approach to work well.

Drupal Six Raised Eyebrow Online Help Manual Really Helps!

Anna | Friday, July 24th, 2009

As of Tuesday, with each new Drupal 6 website we build, we will be providing access to an online manual. Like our paper manual, the online manual describes the basic functions of Drupal in easy to understand language and has customized client-specific content. But the new format also has many new benefits.

Book Module

The online manual uses the Drupal book module, which is a great because the book module lends to organizing things… like a book. The book module automatically creates a listing of the child entries, like a table of contents. You can order the child pages in any way you choose. I also like the book module because is has a printer-friendly version of each page. It does a really nice job of stripping out the unnecessary stuff and optimizing the content for printing, so you don’t get pages broken in half or extra white pages when you print.

Information in a New Dimension

What I loved about moving from a Word document to an online manual is how easily you can cross-reference. With the old manual, you could footnote or reference other pages, but ultimately it had to be a very important reference to disrupt the reader in this way. Now with the online manual, text and images can be linked to other sections of the manual. So if I think a word sounds a little jargon-like, but is still useful, I can add it to the glossary and link the word to its definition. This is great, because it allows us to introduce some language that we might have otherwise shied away from using. This is beneficial in the long run because it helps us develop a more accurate shared language with our clients to talk about their websites.

Keeping the Manual Up to Date

The best thing about the new manual is that if I discover an inaccuracy or a better explain something, I can simply log in and edit the site. Clients instantly have access to the up to date manual. Also, if a client adds a new feature, I can simply add a new page to their online manual and they will instantly have access to the file. This saves sending updated .pdfs and having many trees wasted as manuals are reprinted.

Works Great for Remote Training

We’ve also been experimenting with online meetings for trainings with remote clients and the new manual is great for this. I have three online trainings this summer!

Have You Ever Searched for Drupal Help?

Uhg! Lots of the information available online is too techie for words! Seriously, try Googling “Help Logging Into Drupal” and you’ll see that you get the weirdest stuff! Our help manual covers all the basic functions of editing and creating content for your site. Clients can access it from anywhere and it is constantly growing and evolving. There is a text-based search, allowing you to search the entire contents of your manual instantly, with a listing view of relevant results. It’s a help manual that really helps!

_______________________________

Thanks to the whole team at RE who helped conceive of, build, create content for, and test the Raised Eyebrow Help Website!

SEO friendly drop-down menus for Joomla

Chantel | Thursday, July 2nd, 2009

On my search for a css-list-based SEO friendly drop-down menu that works in older versions of Joomla, specifically Joomla 1.0 I came across this great module called Extended Menu.  It is meant to extend the functionality of the mainmenu module which is a default Joomla module that comes with the Joomla installation.  This module is great because you can use son of suckerfish, suckerfish, mountaintop corners, csstree templates, dtree,  or start from scratch and do-it-yourself.

Below is a step-by-step demonstration on how to get these menus working.

  1. Download the module here
  2. Login to Joomla and go to Installers > Modulesstep 2
    From here you can browse your computer and upload the module you just downloaded from step 1.
  3. Always, always set up a test template and page to play with.  You don’t want your visitors viewing your menu installation in progress across your entire website!
    • Create a copy of an existing template (root > templates > template name) and re-name it to whatever you wish.
    • Create a copy of an existing content item (content > all content items) and rename the content item so you can find it easily.
      step 3b
    • Create a menu item for the new content item you have just created (menu > mainmenu) by clicking on ‘New’.  In this example we will use “Link – Content Item”, click “Next”, follow the on-screen instructions and then click on “Save”.
    • You will need to temporarily publish the menu item you have created by clicking on the Published Icon (should appear as an x for unpublished, and a box with a check mark for published).  Once you have published this menu item, open a new tab in your browser and navigate to the page you have created.
    • Now you will need to apply the template you created earlier (site > template manager > site templates).  Find your template in the list, click the radio button beside it and click on “Assign” in the top right.  You can select multiple pages by pressing command and clicking on the name so be careful not to deselect any pages that may have previously been selected.
      Picture3
    • Now you can un-publish the page you created so it will not show up on your live website.  Repeat step 4D by clicking on the box with a green arrow under the “Published” column.
  4. Now you need to assign the new module to a new position so that we can call it in our template (site > template manager > module positions).  In one of the empty boxes type in a name for your new position.  In this example I have used topnewmenu.
  5. Back to the fun part – coding!  Open up root > templates > template name > index.php
    step 5
    You will need to add <?php mosLoadModules( ‘topnewmenu’ ); ?> to where you would like your dropdown navigation to appear.  It is always a good idea to put a wrapper around this.  In this example I have used id=”nav”.
  6. Now we need to style it! You can do this from scratch or you can download one of the many options listed here.  I would suggest using son-of-suckerfish horizontal menu.
  7. Once you have downloaded the appropriate files, you will need to upload them to your template folder you created earlier in this demonstration (root > templates > template name).
  8. Now all that is left is to style the css (root > templates > template name > css > menu.css) and you have a SEO friendly css-list-based dropdown navigation for Joomla!

Generic caching function for Drupal 6

Chris | Wednesday, June 24th, 2009

One of the pieces of the Drupal performance puzzle is caching. After weeding out a couple of very demanding sql queries in a busy Drupal site, we decided to make more use of Drupal’s caching mechanisms to cut down some of the database load.

Back in 2007, Lullabot’s Jeff Eaton wrote a blog post about caching including a sample implementation for a caching function. This function was almost exactly what we wanted, but we wanted something more generic—a function that we could use in multiple places in the same module or template.php file without modification.

But in order to use one function to populate and retrieve different cache entries, we needed a way to call an arbitrary function from inside the caching function. Fortunately, PHP supports variable functions. This meant that we could pass the name and parameters of an arbitrary function to our caching function and, when necessary, populate the cache with the output from that function (alternatively, we could also have used the call_user_func() function or, like Drupal’s own theme() function, the func_get_args() function).

/**
 * This function returns the cached value for a given cache entry. If the entry does not exist, or if
 * the entry is empty, this function executes the passed function, caches the result and returns it.
 *
 * RENAME THIS FUNCTION FOR USE IN YOUR THEME OR MODULE'S NAMESPACE!
 *
 * @param string $cache_entry The full name of the cache entry--remember the namespace!
 * @param array $function An array with two keys:
 *			string $function['name'] The name of the function
 *			string $function['parameters'] A comma-separated list of parameters
 * @param string $table The name of the cache table to use (see cache_set())
 * @param CACHE_PERMANENT|CACHE_TEMPORARY|unix timestamp $expire Expiry period for this cache entry
 * @param boolean $reset If true, regenerate cache entry; if false, check first
 * @return string|array|object $cache_data The contents of the relevant row in the cache table
 * @see http://api.drupal.org/api/function/cache_set/6
 * @see http://api.drupal.org/api/function/cache_get/6
 */
function theme_name_theme_cache($cache_entry, $function, $table = 'cache', $expire = CACHE_PERMANENT, $reset = FALSE) {
  static $cache_data; // Establish the $cache_data variable for this page load...
  if(!isset($cache_data) || $reset) { // If the variable is not set, or if a cache reset has been requested...
  	if(!$reset &amp;&amp; ($cache = cache_get($cache_entry)) &amp;&amp; !empty($cache-&gt;data)) { // If $cache-&gt;data is set and reset not requested...
  		$cache_data = $cache-&gt;data; // Store the current value of $cache-&gt;data...
  	} else { // If we need to (re) generate the cache...
  		$function_name = $function['name']; // Get the function name to call..
  		$function_parameters = $function['parameters']; // Get the parameters for the function...
  		$cache_data = $function_name($function_parameters); // Set cache data to the return value of the function...
  		cache_set($cache_entry, $cache_data, $table, $expire); // Cache the resulting value...
  	}
  }
  return $cache_data; // Return the cached value...
} // theme_name_theme_cache()

In the above code sample, we pass an array ‘$function’ with two keys, ‘name’ and ‘parameters’ to the function. If the cache is not already populated, we determine the cacheable value with the following line:

$cache_data = $function_name($function_parameters);

We might use this function like this (for illustration purposes only!):

$cache_entry = 'theme_name:website_link';
$function = array(
	'name' => 'l',
	'parameters' => '"Drupal Website", "http://www.drupal.org/"'
);
$table = 'cache';
$expire = time() + (360*24*7);
$output = theme_name_theme_cache($cache_entry, $function, $table, $expire);

This would result in $output being set to the output of the call to Drupal’s l() function, and the cache entry ‘theme_name:website_link’ in the ‘cache’ table being set (or updated) to that value, with an expiry time one week in the future.

Of course the use of a function like this—like the use of the cache in general—should be limited to queries or calculations that are very resource intensive. The example above would actually add overhead compared to simply calling l() directly.

Strange permissions on Coda file uploads

Colin Calnan | Wednesday, June 24th, 2009

I’ve been working with Coda now for a few weeks and it’s been going pretty smoothly. There are a few bugs in the software, or they may even be feature requests :) When creating a file locally and subsequently uploading it to the server the file permissions are set to 700. This was causing all sorts of weirdness on a Drupal site that I’m currently theming. This is definitely a bug, however it’s pretty easy to overcome. In “Preferences -> Transfers” there is an option to “Set permissions on upload”. Set this to 644. This is the recommended permission for files in your theme folder in Drupal. You should now have no more problems when uploading files. If you’ve already uploaded files, it’s pretty easy to change via the command line using the chmod command:

chmod 644 filename.php

coda-pref-screen

coda-file-perms

Theming multiple value CCK fields in Views

Colin Calnan | Monday, June 22nd, 2009

I’m working on a site right now that has a Publications content type, which in turn has a multiple value CCK text field for Author. If more than one author was input I needed them to display as a comma separated list in a view. How do you go about modifying this? My first stop was the theming info link in Views, and that helped me narrow it down to a template file to use, views-view-field.tpl.php(). But that file didn’t allow me to modify the individual fields without getting a whole load of other HTML in the bargain.

< ?php
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $
 /**
  * This template is used to print a single field in a view. It is not
  * actually used in default Views, as this is registered as a theme
  * function which has better performance. For single overrides, the
  * template is perfectly okay.
  *
  * Variables available:
  * - $view: The view object
  * - $field: The field handler object that can process the input
  * - $row: The raw SQL result that can be used
  * - $output: The processed output that will normally be used.
  *
  * When fetching output from the $row, this construct should be used:
  * $data = $row->{$field->field_alias}
  *
  * The above will guarantee that you'll always get the correct data,
  * regardless of any changes in the aliasing that might happen if
  * the view is modified.
  */
?>
< ?php print $output; ?>

Using the brilliant “Theme developer” extension of the Devel module I was able to pin point the theme function – theme_content_view_multiple_field that would allow me to modify the actual value of the field without the wrapper div’s etc (I’m not getting into the views divitis argument.

Here’s a quick snippet of code to place in your template.php file of your theme to allow you to modify multiple value fields:

function custom_theme_content_view_multiple_field($items, $field, $values) {
  $output = '';
  switch($field['field_name']) {
    // If this is the author field then we need to comma separate the authors
    case 'field_author':
      $output .= '<div class="field-item">'. implode(', ', $items) .'</div>';
      break;
 
    default:
      foreach ($items as $item) {
        if (!empty($item) || $item == '0') {
	  $output .= '<div class="field-item">'. $item .'</div>';
	}
      }
      break;
  }
  return $output;
}

I used a switch statement because I have a lot of other multiple fields that need to be themed in different ways and it’s nicer than a whole load of if statements. Also switch provides a default state if a condition isn’t met.

Duplicate results in Webform module Analysis display

Colin Calnan | Tuesday, June 9th, 2009

I came across a problem with the Webform module recently that seemed initially puzzling but on closer examination was actually quite simple.

The Problem

When viewing the webform results in the analysis page it appeared that there were duplicate values for some fields:

webform-analysis-duplicates

The Cause

TinyMCE. It seems that the webform and it’s components may have been created when TinyMCE was disabled and then edited at a later date when it was enabled. The visibility settings for TinyMCE were as follows:

node/*
user/*
comment/*
admin/build/block/*

This meant that TinyMCE was being attached to textareas in the webform component editing pages, usually at ‘node/xx/edit/components/x’.

“select” form components in webforms use a textarea to allow you to input the options for the select field. Each option value is input on a new line in the textarea. With TinyMCE enabled the options had a <br /> tag appended to them. Whenever the site editor edited the form component values, and had TinyMCE enabled, the value of the option changed from “College” to “College<br />”. So any further submissions to the form resulted in the submitted data being recorded as “College<br />”

When running analysis on this data, the results showed up as duplicates

College 34
College 215

due to the <br /> being rendered out in the HTML, it really should have read

College<br /> 34
College 215

The Solution

Turn off TinyMCE for all webform component editing pages. I did this via the Visibility setting in TinyMCE module:

node/add/*
node/*/edit
user/*
comment/*
admin/build/block/*

Now it only shows up on editing nodes and add nodes, not editing form components.

Now for the data. The first thing to do was to sort out the webform component. I tried to run a find and replace on the database in the ‘webform_components’ table, but this didn’t work, so I resorted to editing and re-saving each form component individually. Then I moved to cleaning up the submitted data. I ran a simple find and replace query on this to remove the unwanted <br /> tags:

UPDATE `webform_submitted_data` set `data` = replace(`data`,'&lt;br /&gt;','') WHERE `nid` = NODE_ID_HERE;

This says; Update my webform_submitted_data table by replacing all instances of <br /> in the data table, with nothing, and do this for all data submitted for the webform whose nid(Node ID) is the id of the webform with the funky data.

This worked a treat and the values reset themselves nicely:

webform-analysis-duplicates-2

Drupal Coda Book

Colin Calnan | Thursday, June 4th, 2009

I’d been itching to try out Coda as my development tool, and their recent 3 day sale meant I got a copy for $45. It’s pretty good so far, I have a couple of issues with it that I’ll cover in a later post. One really nice thing about it is the Books feature. This allows you to add reference material to your Coda development environment and search it without having to go to a browser. I’m always needing the Drupal API, well I actually use this one http://drupalcontrib.org/, which is a brilliant Core and Contrib API, perfect for those tricky Views or Webform moments. Setting up a book is really easy, and here is a screen shot of the settings for a book for Drupal 5 and Drupal 6.

Drupal 5 Book settings
Drupal 5 Book settings
Drupal 6 Book
Drupal 6 Book Settings

I also created a nice little Drupal Book icon from the PSD that I found here which was linked to from here (tips on how to insert coda books).

Drupal Coda Book Icon
Drupal Coda Book Icon

Direct link to book icon

 


t. 604.684.2498 | f. 604.721.4007 | e. turningheads [at] raisedeyebrow.com