By aiphes on
hi
i would to convert my D6 themes into D7 but i cant add custom region in node-custom.tpl like for D6
i start from the D7 basic theme
in D6 i've in template.php :
<?php
function cyrano_ca_preprocess_node(&$vars, $hook) {
//Partie regions dans node.tpl- ajoute les regions utiles au node.tpl
$vars['pole_bloc_G'] = theme('blocks', 'pole_bloc_G');
$vars['pole_bloc_C'] = theme('blocks', 'pole_bloc_C');
$vars['pole_bloc_D'] = theme('blocks', 'pole_bloc_D');
$vars['col_G1'] = theme('blocks', 'col_G1');
$vars['col_G2'] = theme('blocks', 'col_G2');
$vars['col_G3'] = theme('blocks', 'col_G3');
...
?>
in D7 i try but it's not work,which function to choose ? :
<?php
function cyrano_er_d7_preprocess_node(&$vars) {
/* Permettre l'ajout de regions dans les node.tpl pour le theming de node
* http://www.victheme.com/blog/drupal-7-printing-block-region-nodetplphp
*/
if ($blocks = block_get_blocks_by_region('region')) {
$vars['colonne_c1'] = $blocks;
$vars['colonne_c2'] = $blocks;
$vars['colonne_c3']['#region'] = 'Colonne C3 - Theming de node';
}
// Add a striping class.
$vars['classes_array'][] = 'node-' . $vars['zebra'];
}
function cyrano_er_d7_preprocess_block(&$vars, $hook) {
// Add a striping class.
$vars['classes_array'][] = 'block-' . $vars['zebra'];
}?>
if someone could explain how to do..thanks
Comments
The two pieces of code are
The two pieces of code are very different, since you do not say what does it work it is hard to provide a suggestion. I can point out that
is likely to cause problems is you print both variables in node.tpl.php since that would produce the same blocks twice resulting in duplicated css id's which should be unique.
Also, it may be possible to use Display Suite or Panels to produce the same results.
so this would be better ?
so this would be better ?
in D6 i use
to include a region in a node-custom.tpl..so i would do the same for D7, but do i modify the php like this ?
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
regions are created in
regions are created in admin/structure/block with this code in template.php:
and in the .info file :
but content isn't displayed...
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
Yeah i get it !
no need to use the code in template.php , but custom regions must to be declared in .info file then in the node.tpl code :
then it rocks.. :)
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
good,Ok.
good,Ok.
Thank you! Its working!
Thank you! Its working!
I'm use it with the views php field