SHARE
TWEET

Steps on Webform

a guest Jan 10th, 2013 397 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function MY_MODULE_node_view($node, $view_mode, $langcode) {
  2.   if ($node->type == 'node_type' && $view_mode == 'full') {
  3.     if ($node->content['webform']['#enabled']) {
  4.       $current_page = (int)$node->content['webform']['#form']['details']['page_num']['#value'];
  5.       $page_count = (int)$node->content['webform']['#form']['details']['page_count']['#value'];
  6.  
  7.       $list = range(1, $page_count);
  8.       $nav = array(
  9.         'type' => 'ul',
  10.         'attributes' => array(
  11.           'class' => 'webform-navigation',
  12.         ),
  13.         'title' => NULL,
  14.         'items' => array(),
  15.       );
  16.       foreach ($list as $v) {
  17.         $nav['items'][$v] = array(
  18.           'data' => t('Step @count', array('@count' => $v)),
  19.         );
  20.         if ($v < $current_page) $nav['items'][$v]['class'][] = 'complete';
  21.         if ($v === $current_page) {
  22.           $nav['items'][$v]['class'][] = 'active';
  23.           $nav['items'][$v]['title'] = t('You are currently on step @count of @full', array('@count' => $v, '@full' => $page_count));
  24.         }
  25.       }
  26.       $node->content['navigation'] = array(
  27.         '#title' => $nav['title'],
  28.         '#items' => $nav['items'],
  29.         '#type' => $nav['type'],
  30.         '#attributes' => $nav['attributes'],
  31.         '#weight' => -10,
  32.         '#theme' => 'item_list',
  33.       );
  34.     }
  35.   }
  36. }
RAW Paste Data
Top