Skip to main content
added 15 characters in body
Source Link
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27

In preprocess_block() function you can only define the title prefix and suffix for each title.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {
 
 // block with 
 title "My$variables['title_prefix'] music"= willarray(
 be wrapped in music'#type' icon=> 'markup',
 if ($variables['block']->title == 'My'#markup' music')=> {'<i class="icon-envelope">',
  );
  $variables['title_prefix']$variables['title_suffix'] = '<iarray(
 class="icon-music">';   '#type' => 'markup',
    $variables['title_suffix']'#markup' ==> '</i>';i>',
 } );
  
}

In preprocess_block() function you can only define the title prefix and suffix for each title.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {
 
 // block with title "My music" will be wrapped in music icon 
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}

In preprocess_block() function you can only define the title prefix and suffix for each title.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {
   
  $variables['title_prefix'] = array(
    '#type' => 'markup',
    '#markup' => '<i class="icon-envelope">',
  );
  $variables['title_suffix'] = array(
    '#type' => 'markup',
    '#markup' => '</i>',
  );
  
}
deleted 644 characters in body
Source Link
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27

Yes, you can do that withIn preprocess_block() function.

just you can only define the title prefix and suffix for each title.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

 // block with title "My music" will be wrapped in music icon 
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}

Your default block.tpl.php already render the prefix and suffix:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php print render($title_prefix); ?>
        <?php if ($block->subject): ?>
            <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
        <?php endif;?>
    <?php print render($title_suffix); ?>
    <div class="content"<?php print $content_attributes; ?>>
        <?php print $content ?>
    </div>
</div> 

Yes, you can do that with preprocess_block() function.

just define title prefix and suffix.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

 // block with title "My music" will be wrapped in music icon 
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}

Your default block.tpl.php already render the prefix and suffix:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php print render($title_prefix); ?>
        <?php if ($block->subject): ?>
            <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
        <?php endif;?>
    <?php print render($title_suffix); ?>
    <div class="content"<?php print $content_attributes; ?>>
        <?php print $content ?>
    </div>
</div> 

In preprocess_block() function you can only define the title prefix and suffix for each title.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

 // block with title "My music" will be wrapped in music icon 
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}
added 773 characters in body
Source Link
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27

Yes, you can do that with preprocess_block() function.

just define title prefix and suffix.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

  // all block titles inwith thetitle content"My regionmusic" will be wrapped in envelopemusic icon
   
 if ($variables['block']->region>title == 'content''My music') {  
    $variables['title_prefix'] = '<i class="icon-envelope">';music">';
    $variables['title_suffix'] = '</i>';
  }
}

also you can do that in block template file using for exampleYour default block--region.tpl.phpblock.tpl.php already render the prefix and suffix:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php print render($title_prefix); ?>
        <?php if ($block->subject): ?>
            <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
        <?php endif;?>
    <?php print render($title_suffix); ?>
    <div class="content"<?php print $content_attributes; ?>>
        <?php print $content ?>
    </div>
</div> 

Yes, you can do that with preprocess_block() function.

just define title prefix and suffix.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

  // all block titles in the content region will be wrapped in envelope icon
   if ($variables['block']->region == 'content') {  
    $variables['title_prefix'] = '<i class="icon-envelope">';
    $variables['title_suffix'] = '</i>';
  }
}

also you can do that in block template file using for example block--region.tpl.php

Yes, you can do that with preprocess_block() function.

just define title prefix and suffix.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

 // block with title "My music" will be wrapped in music icon  
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}

Your default block.tpl.php already render the prefix and suffix:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php print render($title_prefix); ?>
        <?php if ($block->subject): ?>
            <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
        <?php endif;?>
    <?php print render($title_suffix); ?>
    <div class="content"<?php print $content_attributes; ?>>
        <?php print $content ?>
    </div>
</div> 
added 373 characters in body
Source Link
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27
Loading
Source Link
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27
Loading