Drupal and New Campus Template

I've been working with a small team to adapt our new campus template for use in Drupal. While the general direction of campus web presence is to move existing sites towards the Web Content Management System (WCMS), there are a number of use cases where current Drupal sites can't be migrated. These include sites with dynamic dependencies and web applications.

The first web application to roll out in the Drupal version of the campus template was the Campus Interactive Map. In this site, we take advantage of the basic left-column navigation template. It has been created as page.tpl.php and is pulled into the site via SVN. Early versions of the template had the page-front.tpl.php that delivers a slideshow and blocks in a 3x3 or 3x4 layout that replicates the home page layout found on divisional home pages such as humanities.ucsc.edu. Since the map didn't have a front page, I was running a svn up and then deleting the page-front file. Additional iterations of the template design have collapsed the page-front conditional login into the base page.tpl.php file. 

Another site that is being targeted to use the Drupal version of the campus template is the Sustainability Office site. It currently runs in Drupal using a version of the old campus template that I created in 2009. Over time, the objectives of the site have expanded and we are currently implementing functionality called the Project Clearing House that will allow projects to be entered and matched to individuals. You can think of this as a job matching service. Our working prototype can be seen at http://sustainability-dev-2.ucsc.edu. It will change frequently as we work through a number of design and UI issues.

Here's a related article on breadcrumbs.

An Approach to Best Practice

Update 6/14/2011 The team recommended that the Google approach will work best. We'll update the theme settings admin setting to enter a Google Search ID that can be configured by individual webmasters. So the notes below will become moot for most implementations unless a developer needed to use the internal Drupal search.

One approach to developing a template for Drupal that can allow for minor modifications but not hack the core templates is overriding.

For my needs, I need to get the custom search input to show on page and views content. By creating a copy of page.tpl.php and renaming it for two files; page-node and page-content, I'm able to get the UI to work with both types of content.

I also found that when I was overriding with an exact copy of page.tpl -> page-node.tpl, that I was executing check_plain() twice and that was causing some problems with unit titles with apostrophe's.

Here's an example of a search modification. If we want to search the internal Drupal database, we need to point the search internally rather than at Google as we do for the WCMS sites. In the case of the interactive maps site, I am replacing the code as shown below.

page.tpl.php - Google Custom Search

<!-- Google Custom Search -->
<div class="grid_3 omega" id="search">
<form action="http://www.ucsc.edu/search/" id="cse-search-box">
<input name="cx" type="hidden" value="011202561819012672529:sdiwpevx7ba"/>
<input name="cof" type="hidden" value="FORID:10"/>
<input name="ie" type="hidden" value="UTF-8"/>
<input class="query" name="q" type="text" value="Search"/>
<input alt="Search button" class="srchBtn" src="http://static.ucsc.edu/images/search_button.gif" type="image"/>
<!-- end GCS -->
page-content.tpl.php, page-node.tpl.php  - Custom Search
<!-- Google Custom Search -->
<div class="grid_3 omega" id="">
<?php print $search_box; ?>            
<!-- end GCS -->
  • Note that I've pulled search out of the id to avoid creating a CSS override entry that would have to be maintained over time. 
  • I've also pulled the check_plain($title) out of page-node.tpl.php so that it does not execute twice per page. When it does, it creates a htmlentitles problem by printing out the hex value of the apostrophe.
Next Steps
  • Each lead developer will need to figure out how to manage and merge their override templates into the process. For now, I'm just tracking notes, but I'll need to get these changes committed to a repository so that when we run svn up, we pull the core template changes and my custom changes.
  • One of the next issues for our team to discuss is whether or not we want to include the Drupal search as part of its base page.tpl.php template or leave it to site admins to override as I've done here.

Add new comment