drupal - How to place custom views area handler into views header programatically? -
i had accomplish task creating custom views area handler. works fine, , can place handler header area via views ui. unfortunately, due deployment construction on project, can't update code relating view. module creating custom area handler needs alter view place area handler header.
i've created views area handler fine next code:
/** * implements hook_views_data(). * * purpose: found views area handler displaying. */ function custom_shipping_notification_views_data() { // initialize info array. $data = array(); // define handler area used display if qualifies free ship. $data['commerce_order']['free_shipping_message'] = array( 'title' => t('free shipping notification'), 'help' => t('displays free shipping notification on cart form.'), 'area' => array( 'handler' => 'custom_shipping_notification_handler', ), ); // homecoming data. homecoming $data; }
that works, won't handler itself. can place via views ui no problem. need place specific view's header. view managed in features due clients deployment , repo construction cannot alter feature reasonably. need alter view within of module containing custom area.
i have attempted utilize code no avail:
function custom_shipping_notification_views_pre_build(&$view){ if ($view->name == 'commerce_cart_form') { $id = $view->add_item('default', 'header', 'views', 'free_shipping_message'); } }
anyone have ideas? i'm getting murky territory since add_item method has 1 line description, , no coding examples. of documentation around area undeveloped.
function yourmodulename_views_pre_view(&$view, &$display_id, &$args) { if($view->name == 'yourviewname' && $display_id == 'yourdisplayid') { $footer = "this text want in footer!!!!"; $options = array( 'id' => 'area', 'table' => 'views', 'field' => 'area', 'empty' => false, 'content' => $footer, 'format' => 'filtered_html', 'tokenize' => 0, ); $view->set_item('yourdisplayid', 'footer', 'area', $options); } }
drupal drupal-7 drupal-views
No comments:
Post a Comment