Drupal

Jul 26 2010

Theming breadcrumb output with PHP & CSS in Drupal 6

Theming breadcrumb output with PHP & CSS in Drupal 6

We have been developing a Drupal 6 site where we needed more control over breadcrumb theming.

Using the PHP code below, you can get unique & identifying classes to each part of the breadcrumb. You can than use CSS to style it however you like. Add the code to your template.php file in /sites/all/themes/[your theme]. Also make sure to change "yourtheme" to the actual name of your theme. If you don't have this file you can create one. Either way make sure to clear your site cache for your custom breadcrumb classes to show up. That's all there is too it, the rest is up to you in terms of how you style with CSS.


Jun 2 2010

Creating Custom Content Type Page Templates with Drupal & PHP

Creating Content Type Page Templates with Drupal & PHPWe were recently asked to create custom landing pages for a Google ad campaign for a Drupal site we developed. The issue we faced was that the layout for the landing page was not really close to anything in the existing theme.

Drupal by default can do custom node type templates based off any given custom content type (node-blog.tpl.php for example) but all that does is theme and customize the content area. In our case we needed to change the entire page layout. Well it turns out there is a Drupal PHP preprocess function that can help accomplish custom page templates.


May 20 2010

Rewriting Drupal Views Output for Custom Theming & CSS

I love it when we discover one of those wonderful Drupal gems that is not well documented and is very powerful in creating some nice Drupal Views theme customization. We were recently tasked with creating an events calendar that has a custom CCK field called "City". There's a drop down menu with a list of cities to assign the event to. So along with an event listing, you also see a city such as New York or Boston. The client wanted these cities to be color coded.

Rewriting Drupal Views Output for Custom Theming & CSS


May 12 2010

How to Create a Custom Date Format for Better Theming in Drupal Views

 Create a Custom Date Format for Better Theming in Drupal Views


May 10 2010

Custom Body Class with PHP for advanced Theming and CSS in Drupal 6

I recently developed a Drupal site where each page in the site was based on a custom content type and needed some very specific theming. Although my custom theme was based on 960.gs, I decided to borrow from the zen theme its custom body class implementation to give more meaningful CSS classes to leverage for theming.


Apr 23 2010

Promising New Drupal module handles Ubercart SSL pages better than Secure Pages Module

We recently developed an e-commerce Drupal site using the popular module, Ubercart. Ubercart is fantastic as an e-commercie plugin for Drupal.  It's miles ahead of anything that's available for Joomla. However, one thing that Ubercart does not do natively is handle SSL (Secure Sockets Layer) pages. These are secure pages needed when accepting credit card payments on a website in order to properly protect and encrypt payment information given by the purchaser. You know you are on an SSL page when your browser address changes from http:// to https:// . 


Apr 1 2010

How to Customize and Theme Post and Date info in Drupal

When I was theming my blog in Drupal, I decided I wanted a better way to customize and display post info such as wording used and the way date was displayed. The first step is to have a look around and see where the code is coming from that renders this info. I viewed the files in my custom theme folder and discovered these few lines of code in node.tpl.php

  1. <?php if ($submitted): ?>
  2.     <span class="submitted"><?php print $submitted ?></span>
  3.   <?php endif; ?>

In HTML, that is rendered as:
  1. Submitted by highrockmedia on 4-01-10


Mar 5 2010

5 Ways to Enhance Your Drupal Web Site for Good SEO Best Practices

Drupal

**Update, May 28, 2010 (see info below regarding Nodewords)

Drupal is a fantastic platform for developing scalable web sites.  I recently switched from developing most of my web sites in Joomla to Drupal.  As to the reasons why, I’ll save that for another blog post. Once I switched over to Drupal I was keenly interested in finding out the best way to optimize it for good SEO best practices.


Mar 1 2010

Remove Link from Image Attach in Drupal

If you are using the Image Attach module in Drupal, you may not always want to have the image linked. Drupal links the image automatically to its own image node but sometimes you don't want that.

You can add an overide to your theme's template.php file. Note where it says 'your_theme' on line one, replace that with the name if your actual theme. You should also clear your Drupal cache after adding this code.

  1. function your_theme_image_attach_body($node, $iid) {
  2.   $img_size = variable_get('image_attach_size_body_'. $node-&gt;type, IMAGE_THUMBNAIL);
  3.  
  4.   if ($img_size != IMAGE_ATTACH_HIDDEN) {
  5.     drupal_add_css(drupal_get_path('module', 'image_attach') .'/image_attach.css');
  6.  
  7.     $image = node_load($iid);
  8.     if (!node_access('view', $image)) {
  9.       // If the image is restricted, don't show it as an attachment.
  10.       return NULL;
  11.     }
  12.     $class = 'image-attach-body' . ($image-&gt;status ? '' : ' image-unpublished');
  13.     $info = image_get_info(file_create_path($image-&gt;images[$img_size]));
  14.  
  15.     $output = '
  16. </p><div class="' . $class . '">';
  17.     $output .= image_display($image, $img_size);
  18.     $output .= '</div><p>'."\n";
  19.  
  20.     return $output;
  21.   }
  22. }