Skip to content

Instantly share code, notes, and snippets.

@jfitzsimmons2
Last active May 10, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfitzsimmons2/7edc7ac5d69893a9c99dbb9008989b12 to your computer and use it in GitHub Desktop.
Save jfitzsimmons2/7edc7ac5d69893a9c99dbb9008989b12 to your computer and use it in GitHub Desktop.
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME') . '/templates';
// Find all .tpl.php files in this module's folder recursively.
$template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
// Iterate through all found template file objects.
foreach ($template_file_objects as $key => $template_file_object) {
// If the template has not already been overridden by a theme.
if (!isset($theme_registry[$key]['theme path']) || !preg_match('#/themes/#', $theme_registry[$key]['theme path'])) {
// Alter the theme path and template elements.
$theme_registry[$key]['theme path'] = $module_path;
$theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
$theme_registry[$key]['type'] = 'module';
}
}
}
/**
* Implements hook_preprocess_fieldable_panels_pane().
*/
function MODULENAME_preprocess_fieldable_panels_pane(&$variables) {
if ($variables['elements']['#bundle'] === 'FPP_MACHINE_NAME') {
// Preprocess code to be executed if your FPP is used.
// Add the title to the render array so we can print it in the fpp template,
// otherwise, it'll show up ABOVE the template which is silly.
if ($variables['elements']['#bundle'] == 'FPP_MACHINE_NAME') ) {
$variables['content']['title_workaround'] = $variables['elements']['title']['#value'];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment