In my template.php i am executing some inline javascript code. When executing, the result is a white screen of death (WSOD). The web servers error log says:
PHP Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in /template.php on line 89.
Line 89 is this one:
drupal_add_js("(function ($) {$('.altona_1').hover(function() {
And here comes my whole template.php:
<?php
function skh_omega_preprocess_page(&$vars, $hook) {
drupal_add_library('system', 'ui.accordion');
drupal_add_js("(function ($) {$('.altona_1').hover(function() {
$( '.field-collection-container' ).accordion( {
header: 'h4',
active: 2,
collapsible: true
} );
},
function() {
$( '.field-collection-container' ).accordion( {
active: false,
collapsible: true
} );
});
})(jQuery);", array('type' => 'inline', 'scope' => 'footer'));
}
Do i have a wrong markup or what's the matter?
$vars['scripts'] = drupal_get_js();
for? Twice?.. – Mołot Sep 1 '14 at 10:40$
characters with a backslash, or use single quotes (or a nowdoc) to wrap the string. Nothing Drupal-related as such, just PHP – Clive♦ Sep 1 '14 at 13:14