[英]drupal panels ipe toolbar
我向面板ipe工具欄添加了自定義按鈕。 僅當您具有正確的權限以及該頁面為面板化頁面時,才會顯示工具欄。 我還想顯示其他頁面的ipe工具欄,其中包含該頁面的選項卡(查看/編輯/開發/翻譯)。 可能嗎?
是的,這是可能的。 在我的一個項目中,我也有類似的需求。 我在自定義模塊中所做的是:
在代碼中是這樣的:
/**
* Implements of hook_page_alter()
*/
function MYMODULE_page_alter(&$page) {
// Check if Panels IPE is turned on.
if (!module_exists('panels_ipe'))
return;
// Let Panels IPE add the buttons if they exist > If there are no buttons
// then we'll still add the toolbar anyway.
$buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
if (!empty($buttons)) {
return;
}
$output = theme('panels_ipe_toolbar', array('buttons' => $buttons));
$page['page_bottom']['panels_ipe'] = array(
'#markup' => $output,
);
}
/**
* Implements hook_theme_registry_alter().
*/
function MYMODULE_theme_registry_alter(&$theme_registry) {
// Check if Panels IPE is turned on.
if (!module_exists('panels_ipe'))
return;
// Inject our own theme function instead of the one from Panels IPE
$theme_registry['panels_ipe_toolbar']['function'] = 'theme_MYMODULE_panels_ipe_toolbar';
}
// This function is to be adjusted to add buttons and things.
function theme_MYMODULE_panels_ipe_toolbar($vars) {
$buttons = $vars['buttons'];
$output = "<div id='panels-ipe-control-container' class='clearfix'>";
foreach ($buttons as $key => $ipe_buttons) {
$output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>";
// Controls in this container will appear when the IPE is not on.
$output .= '<div class="panels-ipe-button-container clearfix">';
foreach ($ipe_buttons as $button) {
$output .= is_string($button) ? $button : drupal_render($button);
}
$output .= '</div>';
// Controls in this container will appear when the IPE is on. It is usually
// filled via AJAX.
$output .= '<div class="panels-ipe-form-container clearfix"></div>';
$output .= '</div>';
}
$output .= "</div>";
return $output;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.