PHP
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.
Creating Custom Content Type Page Templates with Drupal & PHP
We 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.
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.
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
- <?php if ($submitted): ?>
- <span class="submitted"><?php print $submitted ?></span>
- <?php endif; ?>
In HTML, that is rendered as:
- Submitted by highrockmedia on 4-01-10
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.
-
function your_theme_image_attach_body($node, $iid) {
-
$img_size = variable_get('image_attach_size_body_'. $node->type, IMAGE_THUMBNAIL);
-
-
if ($img_size != IMAGE_ATTACH_HIDDEN) {
-
drupal_add_css(drupal_get_path('module', 'image_attach') .'/image_attach.css');
-
-
$image = node_load($iid);
-
if (!node_access('view', $image)) {
-
// If the image is restricted, don't show it as an attachment.
-
return NULL;
-
}
-
$class = 'image-attach-body' . ($image->status ? '' : ' image-unpublished');
-
$info = image_get_info(file_create_path($image->images[$img_size]));
-
-
$output = '
-
</p><div class="' . $class . '">';
-
$output .= image_display($image, $img_size);
-
$output .= '</div><p>'."\n";
-
-
return $output;
-
}
-
}


