Hello to all!
I have this error when I create in my theme folder the file template.php compiled with the instruction of the readme.txt profileplus module. This is the error:

Parse error: syntax error, unexpected T_FUNCTION in /web/htdocs/www.mariatomarchio.it/home/psslinks/sites/all/themes/colorfulness_theme/... on line 5

My theme is colorfulness, that has not a template.php file so I had create one where I wrote that:

// // --------- code start ------------
/**
 * Override or insert PHPTemplate variables into the templates.
 */
function phptemplate_preprocess_page(&$vars) {
  // ProfilePlus module: remove the Users tab from the search page
  if (module_exists('profileplus')) {
    _removetab('Users', $vars);
  }
}


/**
 * Removes a tab from the $tabs array.
 * ProfilePlus uses this function to remove the 'Users' tab 
 * from the search page.
 */
function _removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach($tabs as $tab) {
    if(strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}

// --------- code end ------------

Then I uploaded template.php in my colorfulness theme folder and I had the error.

I was able to remove the user tab modifying the core user.module where I deleted the function search but I had to do the same every time I update Drupal.

Anyone has some idea about my possible errors or it's a problem linked specifically to my theme? Some solution available?

Thank you very much!
Giuseppe

Comments

James Marks’s picture

Status: Active » Postponed (maintainer needs more info)

When you get an Unexpected T_FUNCTION error, it means that the PHP compiler has encountered a function where it should not be. I don't see anything in the code you supplied that would account for that error, however, and I'm unable to reproduce the error. I'm wondering if you have a non-displaying character in your code somewhere. I'd try copying and pasting the code below over the similar code you placed in your template.php file. Also, don't put a closing php tag ('?>') at the end of the file.

<?php

/**
 * Override or insert PHPTemplate variables into the templates.
 */
function phptemplate_preprocess_page(&$vars) {
  // ProfilePlus module: remove the Users tab from the search page
  if (module_exists('profileplus')) {
    _removetab('Users', $vars);
  }
}


/**
 * Removes a tab from the $tabs array.
 * ProfilePlus uses this function to remove the 'Users' tab 
 * from the search page.
 */
function _removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach($tabs as $tab) {
    if(strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}
James Marks’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Changing status.