Created
September 11, 2015 08:49
-
-
Save guoxiangke/7192fc1c82b0bf6e3b2e to your computer and use it in GitHub Desktop.
print block in template with contextual-links 在模板中打印block 带有编辑连接!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module_load_include('inc', 'block', 'block.admin'); | |
global $theme_key; | |
$blocks = block_admin_display_prepare_blocks($theme_key); | |
foreach ($blocks as $key => $block) { | |
if($block['info']=='Social Views txt3') $block_delta1=$block['delta']; | |
if($block['info']=='Social Views txt4') $block_delta2=$block['delta']; | |
} | |
$block_text1 = module_invoke('block', 'block_view', $block_delta1); | |
$block_text2 = module_invoke('block', 'block_view', $block_delta2); | |
$links1 = array( | |
'edit-term' => array( | |
'title' => t('Edit Block'), | |
'href' => url('/admin/structure/block/manage/block/'.$block_delta1.'/configure', array('absolute' => TRUE, 'query' => array('destination' => current_path()))), | |
), | |
); | |
$links2 = array( | |
'edit-term' => array( | |
'title' => t('Edit Block'), | |
'href' => url('/admin/structure/block/manage/block/'.$block_delta2.'/configure', array('absolute' => TRUE, 'query' => array('destination' => current_path()))), | |
), | |
); | |
$contextual_links1 = array( | |
'#prefix' => '<div class="contextual-links-wrapper">', | |
'#suffix' => '</div>', | |
'#theme' => 'links__contextual', | |
'#links' => $links1, | |
'#attributes' => array('class' => array('contextual-links')), | |
'#attached' => array( | |
'library' => array(array('contextual', 'contextual-links')), | |
), | |
'#access' => user_access('administer taxonomy'), | |
); | |
$contextual_links2 = array( | |
'#prefix' => '<div class="contextual-links-wrapper">', | |
'#suffix' => '</div>', | |
'#theme' => 'links__contextual', | |
'#links' => $links2, | |
'#attributes' => array('class' => array('contextual-links')), | |
'#attached' => array( | |
'library' => array(array('contextual', 'contextual-links')), | |
), | |
'#access' => user_access('administer taxonomy'), | |
); | |
$block1 = array( | |
'content' =>array('#markup'=>$block_text1['content']), | |
'contextual_links' => $contextual_links1, | |
); | |
$block2 = array( | |
'content' =>array('#markup'=>$block_text2['content']), | |
'contextual_links' => $contextual_links2, | |
); | |
?> | |
<?php if (!empty($title)) : ?> | |
<h3><?php print $title; ?></h3> | |
<?php endif; ?> | |
<div class="social_txt contextual-links-region"> | |
<?php print drupal_render($block1);?> | |
</div> | |
<div class="social_txt dale-bfff contextual-links-region"> | |
<?php print drupal_render($block2);?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment