Skip to content

Instantly share code, notes, and snippets.

@alexfinnarn
Last active August 9, 2018 17:17
Show Gist options
  • Save alexfinnarn/116616247914bea5027f2742311975b3 to your computer and use it in GitHub Desktop.
Save alexfinnarn/116616247914bea5027f2742311975b3 to your computer and use it in GitHub Desktop.
no page_alter
<?php
/**
* Implements hook_page_alter().
*/
function code_syntax_highlighting_bundle_page_alter() {
// Add the JS and CSS assets if the page is supposed to have code syntax highlighting.
$current_object = menu_get_object();
if (in_array($current_object->type, config_get('code_syntax_highlighting_bundle.settings','csh_enabled_node_types'), TRUE)) {
backdrop_add_css(backdrop_get_path('module', 'code_syntax_highlighting_bundle')
. '/libraries/highlightjs/styles/' . config_get('code_syntax_highlighting_bundle.settings','csh_theme') . '.css');
backdrop_add_css(backdrop_get_path('module', 'code_syntax_highlighting_bundle')
. '/css/csh.css');
// @todo Update the library and provide instructions to override the custom packaged build.
backdrop_add_js(backdrop_get_path('module', 'code_syntax_highlighting_bundle')
. '/libraries/highlightjs/highlight.pack.js');
backdrop_add_js('jQuery(document).ready(function () { hljs.initHighlightingOnLoad(); });', array(
'type' => 'inline',
'scope' => 'footer',
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment