I'm new at Drupal, so please help to solve the problem. :) I've found an article: Change templates based on path alias

It describes my situation. But when I include described code or just this line:

function lm_sr4_preprocess_page(&$vars) {}

In mywebsite.com/sites/default/themes/lm_sr4/template.php it just causes this error:

Fatal error: Cannot redeclare lm_sr4_preprocess_page() (previously declared in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/template.php:11) in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/preprocess/page.preprocess.inc on line 10

Here's all template.php code:


 * @file
 * Template overrides as well as (pre-)process and alter hooks for the
 * lm_sr4 theme.

function lm_sr4_preprocess_page(&$vars) {
  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) && $alias_parts[0] == 'ep') {
    $vars['theme_hook_suggestions'][] = 'page__epcustomtemplate';

function lm_sr4_views_tree_inner($variables) {

  $view = $variables['view'];
  $options = $variables['options'];
  $rows = $variables['rows'];
  $title = $variables['title'];
  $result = $variables['result'];
  $parent = $variables['parent'];

  $items = array();
  foreach ($result as $i => $record) {
    if ($record->views_tree_parent == $parent) {
      $variables['parent'] = $record->views_tree_main;
      $items[] = $rows[$i] . call_user_func(__FUNCTION__, $variables);
  return count($items) ? theme('item_list', array(
    'items' => $items,
    'type' => $options['type'],
    'attributes' => array(
      'class' => array(
  )) : '';

function lm_sr4_omega_layout_alter(&$layout) {
  if (arg(0) == 'eparchies') {
    $layout = 'eparchy';

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

2 Answers 2


You have the function lm_sr4_preprocess_page() declared twice; once in template.php (line 11) and once in preprocess/page.preprocess.inc (line 10).

You need to merge those two functions together, you can only declare a function once in PHP.


The error said you are use function name as name used by another fucntion Fatal error: Cannot redeclare lm_sr4_preprocess_page() (previously declared in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/template.php:11) in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/preprocess/page.preprocess.inc

you just need change you function name and every thing work correctly. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.