I came across some threads dealing with this, but they're all quite specific and therefore confusing.
What's the best practice to combine multiple functions in general? I'm using this in a template.php file of a Drupal installation for theming purposes.
Say I have two functions:
function mytheme_preprocess_page(&$variables){
(...)
}
and
function mytheme_preprocess_page(&$vars, $hook){
(...)
}
When I use these two functions in my template.php, I'm getting the fatal error: Cannot redeclare mytheme_preprocess_page() (previously declared in (file).
Here's the full code:
function mytheme_preprocess_page(&$variables){
// Add information about the number of sidebars.
if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
$variables['content_column_class'] = ' class="col-sm-6 main-content"';
} elseif (!empty($variables['page']['sidebar_first']) || !empty($variables['page']['sidebar_second'])) {
$variables['content_column_class'] = ' class="col-sm-9 main-content"';
} else {
$variables['content_column_class'] = ' class="col-sm-12 main-content"';
}
}
function mytheme_preprocess_page(&$vars, $hook){
if (isset($vars['node'])) {
switch ($vars['node']->type) {
case 'article':
$vars['title'] = '';
break;
}
}
}
I understand I should merge these functions. Question is: how?
Because these (&$variables) and (&$vars, $hook) seem to be necessary for every separate part.