Skip to content

Instantly share code, notes, and snippets.

@csakiistvan
Created July 1, 2014 14:32
Show Gist options
  • Select an option

  • Save csakiistvan/669c3e33e3b5c89df0f9 to your computer and use it in GitHub Desktop.

Select an option

Save csakiistvan/669c3e33e3b5c89df0f9 to your computer and use it in GitHub Desktop.
how to create a translatable drupal pane title
<?php
/**
* Implements hook_preprocess_panels_pane().
*/
function hook_preprocess_panels_pane(&$vars) {
// Allow translation before substitution.
if (
!empty($vars['pane']->configuration['override_title'])
&& !empty($vars['pane']->configuration['override_title_text'])
&& module_exists('ctools')
) {
$raw = $vars['pane']->configuration['override_title_text'];
// @codingStandardsIgnoreStart
$raw_translated = t($raw);
// @codingStandardsIgnoreEnd
$context = isset($vars['display']->context) ? $vars['display']->context : array();
$vars['title'] = filter_xss_admin(ctools_context_keyword_substitute($raw_translated, array(), $context));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment