Advertisement
Guest User

Steps on Webform

a guest
Jan 10th, 2013
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement