By cococom64 on Sat, 12/05/2015 - 20:45
Forums:
Hello,
For the purpose of creating 3D card flip effects on a specific node, I added js scripts in the html.tpl.php template of BerryPro theme.
In Drupal 6, I could rename this template this way : "page-node-394.tpl.php" but it seems not to work with Drupal 7 and I should add the code in the global template "html.tpl.php".
As I intend to add other sliders, I would like to know if I can use another way than adding code always in the general file ?
Thanks in advance for your reply.
Comments
If you want to add any global (available for all pages) CSS / JS file, you can simple add in /tmplates/html.tpl.php
If you want to add a js file for a specific node only, please follow below steps.
Change 123 to node ID of your page.
Done!!!
If you want to add js file for homepage only, add below code in template.php
Thanks for your quick answer.
I am going to try these different ways of customizing header sections.
Hello,
I have a problem with the solution consisting in changing the template.php and I have this error message :
Notice : Undefined variable: node dans include_once() (ligne 12 dans /var/www/drupal/hiddendossier/drupal7dev/sites/all/themes/berrypro/template.php).
Notice : Trying to get property of non-object dans include_once() (ligne 12 dans /var/www/drupal/hiddendossier/drupal7dev/sites/all/themes/berrypro/template.php).
Thank you in advance for your help.
Best regards
Hello,
It seems I found the solution by writing the condition inside the function berrypro_preprocess_node(&$variables) as you can see below :
function berrypro_preprocess_node(&$variables) {
$variables['submitted'] = t('By: !username', array('!username' => $variables['name']));
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
$node = $variables['node'];
$comment = $variables['comment'];
$variables['submitted_day'] = format_date($node->created, 'custom', 'j');
$variables['submitted_month'] = format_date($node->created, 'custom', 'M');
$variables['submitted_year'] = format_date($node->created, 'custom', 'Y');
if ($node->nid == 6350) {
function berrypro_js_alter(&$javascript) {
$javascript['misc/jquery.js']['data'] = drupal_get_path('theme', 'berrypro') .
'/js/jquery.js';
$javascript['misc/jquery.js']['version'] = '1.10.2';
}
}
}
As I am not a developper I hope this solution is correct even if it solves my problem to display tab shortcodes for Berrypro in a specific node.
Thanks in advance for your advise.
Best regards