Community Documentation

Altering the Author Pane template

Last updated August 11, 2010. Created by Michelle on April 16, 2009.
Edited by Stephen Scholtz, mradcliffe. Log in to edit this page.

Author Pane comes with many variables displayed by default because it is easier for non coders to take away than to add. Depending on what integrated modules you have installed on your site, the Author Pane can get quite busy. Fortunately, it is completely customizable without having to hack the module.

The first thing you need to do is determine what template file you are using. This is the trickiest part because Author Pane is designed to be made use of by other modules. You can use the theme developer submodule that comes with the Devel module to help. Another option is to add this code to your template.php and then clear the cache:

<?php
function THEMENAME_preprocess_author_pane(&$variables) {
 
$variables['show_template_location'] = TRUE;
}
?>

You should now see a the path to the template file on all your Author Panes.

Here are some likely candidates:

  • author-pane.tpl.php: This is the default and is used if you call Author Pane as a theme function.
  • advanced_forum.STYLE_NAME.author-pane.tpl.php: This is used and provided by Advanced Forum.
  • advanced_profile_author-pane.tpl.php: This is used and provided by Advanced Profile on the user pages.
  • advf-author-pane.tpl.php: This is the Advanced Forum 1.x version.

You will find these in the project directory tree for the respective modules. You will want to copy the file to your theme and modify it there rather than changing the copy in the project directory to avoid upgrade problems.

Once you've figured out which file is in use, open it up in a text editor. If you are editing the original author-pane.tpl.php that comes with Author Pane, you will see a large list of comments at the top which list all the available variables. If you are editing any other version, you'll want to open a copy of author-pane.tpl.php as well so you can see them.

What follows may look like greek if you don't know PHP but it's actually fairly simple. Most of it is HTML to define the DIVs. Here is an example:

  <?php if (!empty($contact)): ?>
    <div class="author-pane-line author-contact">
      <?php print $contact; ?>
    </div>
  <?php endif; ?>

The first line says "if the variable holding the contact line is not empty". The second line creates a DIV with a class that says this is a single line and another class that says specifically what line it is. It then follows with the line that actually prints the link stored in the variable $contact. The last line "closes" the question in the first line.

If you're comfortable with HTML, you can change things around quite a bit. Just remember that <?php print $contact; ?> is all one unit that will print out what's in the variable, which is the word that starts with $ and that the variable list is at the top of author-pane.tpl.php.

If you want to add more variables, you will need to learn how to use the preprocess system.

When you're done, make sure to do a hard refresh of the page. You may also need to clear your cache (under performance) to get your change to show up. If neither of these work, you are probably not changing the right file.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders, Site administrators, Themers

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.