2

I have a series of pages that provide paged tables inside of tabsets. Using the Tabs module, I get jQuery UI tabs, and I am using that to create pages with multiple horizontal tabs; inside those tabs I have forms and paged tables, typically one form or one paged table per tab.

The paged tables are generated using pager_query(), where I am providing a pagerElement parameter because I have multiple paged tables on the same page (but on different tabs).

Likewise, when I call theme('pager'), I am passing in my pagerElement so my multiple paged tables do not get confused, as well as an additional associative array for my active tabset parameter. The call looks like theme('pager', NULL, $pagerLimit, $pagerElement, array('tabset'=>$pagerElement));.

The issue I'm having is the pager links being generated, for example: when first landing on one of these multi-tabbed pages, the pager links look like http://example.com/Projects-Dash?tabset=0&page=1.

However, as soon as a pager link is clicked, the pager links look like http://example.com/Projects-Dash?tabset=0&page=2&tabset=0, where tabset=0 is repeated. At least the links from the second paged table are somewhat different, looking like this http://example.com/Projects-Dash?tabset=1&page=1%2C1&tabset=0, but they still have that extra tabset=0 at the end.

How do I prevent that?

1 Answer 1

1

The problem was being caused by how the pager logic handles existing URI encoded parameters: it simply copies them, pre-pending any new URI encoded parameters used by the pager logic. The result being a duplicate of my 'active tab' parameter "tabset", the previous one present in a copy of the prior URI parameters, and the one I introduced in the paging link.

My solution was to parse the request URI myself inside my form logic, with knowledge that the first encountered "tabset" value is the active one, not the second (older) version at the end of the URI.

$activeTab = 0;
  $requestUri = $base_root.request_uri();
  if ($requestUri == '') {
    _devReport( '$requestUri is empty!' );
  }
  else {
    $requestArray = explode( '/', rawurldecode($requestUri) );
    // if course, this parsing logic is specific to my WebApp URI setup:
    if (($requestArray[0] == 'http:') &&
        ($requestArray[3] == 'WebApp')) {
      // this should always be true, but just in case:
      if ($requestArray[4] != '') {
        $split1 = explode( '?', $requestArray[4] );
        $split2 = explode( '&', $split1[1] );
        if ($split2[0] != '') {
          $split3 = explode( '=', $split2[0] );
          if ($split3[0] == 'tabset') {
            $activeTab = $split3[1];
          }
        }
      }
    } 
  }

Now $activeTab has the correct value, even though it may be present a 2nd time in the URI with a different value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.