1

My company purchased a theme, "Porto" which also has a subtheme, "Porto Sub". Porto had a template.php file, Porto Sub, did not. This is all in Drupal 7.

I wanted to make a change to the porto_menu_link() function so that I could support nolink menu entries. Best practice seemed to be to make those changes in a template.php file under the themes\Porto_sub\ folder. I created a template.php file in that location and added this content, almost all of which I had copied from the porto_menu_link function from the original themes\Porto\template.php:

<?
function porto_sub_menu_link(array $variables) {
  unset($variables['element']['#attributes']['class']);
  $element = $variables['element'];
  static $item_id = 0;
  $menu_name = $element['#original_link']['menu_name'];

  ... snipped some code out here ...

  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . '</li>';
}

?>

But my function was not not being called. I thought it might have something to do with it being a sub template, so I altered the same code in porto_menu_link in the original themes\Porto\template.php. Still no dice. I even deleted the porto_menu_link function in template.php and it didn't change anything. I cleared caches between all steps and I'm essentially out of things to try. Anybody know why this wouldn't work?

  • If you deleted a function out the template.php file in a working theme and cleared caches and that had no effect on things, then I can't find any rational reason how that template.php was being used in the first place.... so, I would check to see if you might have possibly installed this theme in another directory as well as in the one you are modifying, and the other one is the one being picked up. eg, if it exists in themes/porto and sites/all/themes/porto by mistake. – Jimajamma Mar 26 '14 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.