8th March 2011
I often like to use template files to alter the HTML of a view to cut down on the masses of redundant markup that Drupal creates. But I just came across a problem where I was unable to get the file path of an image in my content type, despite the fact that the image was output in the view settings.
var_dump($row) gave the following:
["nid"]=> string(2) "27" ["node_data_field_contenttype_teaser_field_imagefield_fid"]=> string(1) "9" // The field names will change depending on the name of your content type and CCK image field
along with some other fields which provided no other useful information.
I stumbled across the function field_file_load which solved all my problems.
$image = field_file_load($row->node_data_field_contenttype_teaser_field_imagefield_fid);
You can then use $image[‘filepath’] to create an image element.
I also discovered that the function has been renamed in Drupal 7 - use file_load() instead.
I often develop sites on my local machine before committing and transferring to a staging/live server, so during the development phase most of my sites reside on a URL similar to http://localhost:8800. …
17th May 2011read more »
I was just developing a Block View in Drupal for a freelance project, where the markup on the first row was different to the subsequent rows. I needed to change the markup to display an image and teaser, while the subsequent rows just has the title (which links to the node) and published date. …
13th April 2011read more »