Blogs

Load a custom page-xxxx.tpl.php file for Drupal

This snippet is so you can override page.tpl.php and create a custom layout for page-some-content-type.tpl.php and it will override using the page.tpl.php template.

Add this code between the head tags in your page.tpl.php file.

<?php if ($node->type == 'some-content-type'):  ?>
        <?php include 'page-some-content-type.tpl.php'; /*load a page-some-content-type.tpl.php */
       
return;  ?>
  
  
<?php endif; ?>

Replace, "some-content-type" with the name of the content type's page you are trying to change.

Add unique class to menu items (Drupal 6)

In my ever increasing quest to make a more user friendly Drupal environment for my clients. I have been trying to figure out how to add a unique class to menu items. Recently I came across this snippet on drupal.org.

In order to use this snippet, you must place this code in your theme's template.php file.

<?php
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
   
$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  if (!empty(
$extra_class)) {
   
$class .= ' '. $extra_class;
  }
  if (
$in_active_trail) {
   
$class .= ' active-trail';
  }

  if (!empty(
$link)) {
           
// remove all HTML tags and make everything lowercase
           
$css_id = strtolower(strip_tags($link));
           
// remove colons and anything past colons
           
if (strpos($css_id, ':')) $css_id = substr ($css_id, 0, strpos($css_id, ':'));
           
// Preserve alphanumerics, everything else goes away
           
$pattern = '/[^a-z]+/ ';
           
$css_id = preg_replace($pattern, '', $css_id);
           
$class .= ' '. $css_id;
    }
    return
'<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
?>

This code will add a class based on the link's title. The only problem I see with this method is that if you use the class and then change the name of the link, it will also change the name of the class, so keep that in mind when using this snippet. Other than that, I will be adding this to my snippet library.

Mix Media Design web site

mix media design image

Client wanted a simple, modern, and clean web site to display some of their services.

I used an image of a palette mixing colors to communicate the mixing aspect of the business.

In addition, I created a progression of colors where the services are highlighted. They start with yellow, blue, and finally green. The last one is green to show yellow and blue have mixed together to make green.

The site runs on Drupal content management system.

Customize the date format for the node and view template

This tutorial assumes a knowledge with drupal themes and how to customize them.

In order to customize the date for the node template, a preprocess function must be created in the template.php file.

function yourthemesname_preprocess_node(&$vars) {
$node = $vars['node'];
$vars['date_day'] = format_date($node->created, 'custom', 'j');
$vars['date_month'] = format_date($node->created, 'custom', 'M');
$vars['date_year'] = format_date($node->created, 'custom', 'Y');
}

Then add the variables to your node-xxxx.tpl.php:

<div class="date-block">
    <span class="month"><?php print $date_month; ?></span>
    <span class="day"><?php print $date_day; ?></span>
    <span class="year"><?php print $date_year; ?></span>
</div>

Finally add style it with css.

Customizing the date within a views template
What if you want to do the same thing with a view template? It's pretty much the same thing but there are a few changes.

Create a new template for the "created" field in your view. Add this code:

<?php

    $day
= format_date($row->node_created, 'custom', 'd');
   
$month = format_date($row->node_created, 'custom', 'M');
   
$year = format_date($row->node_created, 'custom', 'Y');
   
?>


<div class="date-block">
<span class="month"><?php print $month; ?></span>
    <span class="day"><?php print $day; ?></span>
    <span class="year"><?php print $year; ?></span>
</div>

Finally style with CSS.

Party Designer Inc. Logo Design

Custom logo design for Party Designers Inc.

Klopp's Restoration and Remodeling logo design

Custom logo designed for Klopp's restoration and remodeling.

Custom web site for Platinum Associates

Web site built using Drupal CMS.

Features include:
--Slide show
--Contact page
--Services page

Show fields from current node in Block View

This tutorial assumes a working knowledge of drupal, views, and cck.

I have been working on a project management system for us and our clients. I created a progress bar that visually shows how close a project is to completion. I wanted to show this progress bar in a block on the project page. In order to do this, I needed to create a block view. I wanted to share how easy this is because I really didn't find too much about it.

First, create a new view and call it anything. I used an existing view I had and added a new display block title, 'Progress bar Block'.

Next, add whatever fields from the node you would like to display. In my case, I added the cck percentage field I was using for the completion field. Once the field is setup, an argument needs to be created (the argument is sort of like a filter but you are using the URL to filter the content).

The settings I used for the argument are as follows:
--Node: Nid
--Provide default argument
--Node ID from URL
--I left everything else default

Once the view is setup, the block will need to be place into any region in your theme. In my opinion, this is a VERY easy and cool trick to add some variety to your pages.

The Network Group of Palmyra, PA

Network Group of Palmyra Pa Logo

This was a simple logo I did for a network group that I attend in my area. The idea was pretty simple. They wanted something simple and professional.

I started thinking about networking and how it is a bunch of different people getting together to share ideas, experiences, and clients. So I wanted to create a mark that sort of showed different pieces connecting and I wanted to make it simple and clear. I basically just took four boxes and connected them with another box on the inside to give the look of the boxes being connected even though they were separate.

The 1 problem that came from this mark was that when it was not in the position that it is in now, it looked too much like there was some sort of cross in the middle. As a result, I decided to give it an angle which I thought helped the overall composition.

I wanted a sort of more formal/professional font to be used for the words, "The Network Group". We are all professionals and I wanted the group to be represented as such. With that in mind, I chose a serif font to represent the name and I gave the overall logo a center alignment to give it a more formal look.

The words, "Palmyra, Pennsylvania" are of secondary importance so I use a softer font and color. I felt this part of the type was not as important as the name but it was important enough to be included.

Overall, I think the logo turned out very nice and the client is pleased.

Features Module

The features module is a really great module. Features allows you to pack up a certain configuration for a site into a module and then use it on another site. For example, lets pretend you always use the same configuration for a blog setup on a site. Lets pretend that configuration includes that views module (with a couple different views), image cache, contexts, permissions, etc. The features module will pack up all of the settings for that configuration into a module that may be used on another site.

Features is extremely useful to save time, especially in situations where you find yourself using a particular configuration over and over again. I would highly recommend this module. If you would like to check it out, follow this link.