Displaying your Drupal Mission Statement on Multiple Pages
While many sites don't need to utilize a mission statement, it can be useful for adding static content to your theme.
I needed to add copy to the header for a client that would appear on all pages, that they could easily edit and wouldn't involve any editing of the theme files. I immediately thought to use the mission statement that's available at admin/build/themes/settings. The only problem being that by default, the Drupal mission statement only appears on the home page.
You can add the logic to your page.tpl.php, but it's best practice to keep your site's logic separate from your design.
- Make sure that 'Mission statement' is checked at admin/build/themes/settings
- Fill out your 'Mission statement' at admin/settings/site-information
- Update your theme files (see below)
- If you are adding the function phptemplate_preprocess_page(&$vars) to your template.php file for the first time, don't forget to flush the theme registry.
template.tpl.php
<?php
function phptemplate_preprocess_page(&$vars) {
/**
* Mission statement
*
* the mission statement (admin/settings/site-information) is only available
* to the homepage. make it available to all pages.
*/
$vars['mission'] = theme_get_setting('mission', FALSE);
}
?>page.tpl.php
Add the following to wherever you'd like the mission statement to appear. Note the id 'mission' can be changed to anything you like.
<?php
if (!empty($mission)) { print '<div id="mission">'.nl2br($mission).'</div>'; }
?>Comments
Yep, worked as advertised. Worth adding this bit, probably commented out, to the default template.tpl.
I am using the blueprint theme myself.
Thanks :-)
Add comment
jsfwd on Twitter
- BIXI debuts bike sharing program in Toronto http://bit.ly/cTruQl 1 day 21 hours ago
- Vote #Toronto to host DrupalCon 2012 North America http://bit.ly/aXgBkJ 3 days 19 hours ago
- Toronto #Drupal meetup tonight 6:30pm @CSI http://bit.ly/cGL63w 4 days 19 hours ago
- Display a Twitter Profile using YQL & jQuery http://bit.ly/ajAfu6 5 days 21 hours ago
- Google Images got a facelift.... size, type & colour filters... pagers gone... wow! 1 week 2 days ago
- Wouldn't that just be Drupal? RT @becircle: I just heard the words I feared I might hear some day "They created a GUI for Drush" #drupal 1 week 3 days ago
- #Raptors acquire Leandro Barbosa... w00t w00t!! 2 weeks 5 days ago
- The NBA is a whole lot less interesting today. 3 weeks 22 hours ago
- Site Aliases, Groups and Remote Capabilities! RT @lwalk: New features in Drush 3 http://bit.ly/aIzmxw #drush #drupal 4 weeks 2 days ago
- Twitter delays the OAuthcalypse another 6 weeks http://countdowntooauth.com 4 weeks 3 days ago
This evidently works but is also one of the occasions that I wonder about the 'drupal best practices' .
Here's what I mean. If you are building a theme then doing what you suggest makes absolute sense. Various users can input their own mission statement into your theme.
However, it makes no sense at all if you are building a single site. Why not just put the text in the page.tpl.php file? No pre-processing, no complication, no server load, no problems. Unchanging elements of the page should go in the page.tpl.php file. This bit of text is an unchanging element of the page (unless of course you envisage changing your mission statement frequently.)
Just because we have a super powerful content management system doesn't mean that we have to use it to crack even the smallest of nuts.....