Welcome to Look Alive! Blog of Alli Price, a Developer living in the UK who works with Drupal and lots of other fun stuff (including Harmony Forum)!

Posted: Monday, September 15th 2014

Want to install ImageMagick on Mac OS? OK then, just use Homebrew and your life will be easier.

First up install Homebrew by following these instructions: http://brew.sh

Missing Ruby? https://rvm.io/

Once you've got those two, do the following...

sudo brew install gs

sudo brew install libpng

sudo brew install imagemagick

Posted: Saturday, February 8th 2014

At.js in action

A dev release is out for At.js, a module implementing the work of iChord which allows for autocompletes within textareas. This type of autocomplete can be seen on Github and Twitter, and now Long text fields within Drupal can have this too.

The module works by creating At.js Listeners (which are Features exportable), editing the Long text field(s) and selecting which listeners should be active on it and finally enabling the listeners on input formats (this last part isn't necessary but recommended).

Posted: Tuesday, January 28th 2014

There are some good examples out there on how to create a custom Entity reference Behaviour plugin, but not so much for Selection handlers.

Why would you want to do this? A number of reasons. For me it was because the base Entity reference selection handler wasn’t returning correct results on an autocomplete field and I've got custom access rules to consider. An alternative to making our own would be to use Views, but this idea doesn’t appeal due to the performance overhead compared to EntityField Query.

Posted: Monday, January 27th 2014

Too long! Incoming wave of posts about things I've learned creating Harmony Forum, mostly around Entity API and Entity reference…

Posted: Monday, February 13th 2012

If you ever used the Pathauto module and the very useful [menupath-raw] token in Drupal 7 this is gone.

Using the latest stable release of Token module, this is now the way!



The use case for this would be that you have a page at /shop, and you want to create a sub-page under it (let's say we're creating a Help page), and have that hierarchy reflected in the URL, you'd set the parent menu item for your new node as "Shop", then you'd get the URL:


If you just had the node at the top level of a menu, not nested in any way you'd get:


Important! To prevent pathauto stripping out slashes found within tokens you must go to Pathauto's settings, under punctuation for "Slash" (/) set this to "Do nothing". Don't worry about double slashes as Pathauto will take care of that for you.

Posted: Wednesday, August 31st 2011

So far this year has had a lot of (justified) noise bounced about advocating responsive design, not so long ago Henrik Eneroth did an excellent post and suggested re-design of the browser as we know it. Pulling out responsive design from within the browser viewport to the application level.

The results make a lot of sense, elevating the buzz wordy "responsive" design from just something for web designers, but as a way of thinking to design in general.

Here's his original post (via @cameronmoll):


Mozilla have released screenshots of the user interface for Firefox for Honeycomb Android tabets which is very close to what's described in the original post, not quite a full blown re-think of the browser for the desktop, but a move in the right direction, and a signal that Mozilla are very much switched on.

Posted: Sunday, August 21st 2011

Here's a couple tips for views theming, great fun! Also an opportunity for the longest post title in the world.

First, How to get the row id from within the fields template.

When doing your own custom views theming, it can be useful to know which row number you're currently working with. A good example of this usage would be super-sizing certain elements for the first row of a listing.

To begin let's take a look at the default fields template views-view-fields.tpl.php.

* @file views-view-fields.tpl.php
* Default simple view template to all the fields as a row.
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
*   - $field->content: The output of the field.
*   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
*   - $field->class: The safe class id to use.
*   - $field->handler: The Views field handler object controlling this field. Do not use
*     var_export to dump this object, as it can't handle the recursion.
*   - $field->inline: Whether or not the field should be inline.
*   - $field->inline_html: either div or span based on the above flag.
*   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
*   - $field->wrapper_suffix: The closing tag for the wrapper.
*   - $field->separator: an optional separator that may appear before a field.
*   - $field->label: The wrap label text to use.
*   - $field->label_html: The full HTML of the label to use including
*     configured element type.
* - $row: The raw result object from the query, with all data it fetched.
* @ingroup views_templates

<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <?php print $field->wrapper_prefix; ?>
    <?php print $field->label_html; ?>
    <?php print $field->content; ?>
  <?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>

At the top of the file you've got a listing of the variables available to you, very useful! But there is an extra variable not listed: $id.

At a guess, it's not mentioned as the variable name is re-used in the foreach loop, before this point you can re-assign it or re-use it.

Depending on the nature of theming we are carrying out, sometimes it's necessary to have a specific HTML structure to each row, here's an example of this, making use of $id to add an extra class to the first item.

// $Id$
* @file views-view-fields.tpl.php

$wrapper_classes = 'wrapper';

if (
$id == 0) {
$wrapper_classes .= ' supersize';

<div class="<?php print $wrapper_classes; ?>">
  <div class="left image">
  <?php print $fields['field_image_fid']->content; ?>
  <div class="left text">
  <h2><?php print $fields['title']->content; ?></h2>
  <?php print $fields['teaser']->content; ?>

Second, How to tell how many total rows a view has found, not just the number it's currently displaying.

This one's actually really easy, where-ever you have a view, in a view template, when running a view in code, you can do:

= views_get_view('view_machine_name');


One caveat, for this to work, your view needs to be using a pager. If you're not there are other ways, but it's a bit more involved.