title: How To Handle Tasks and variables in router File in Joomla
body: <p>I have Browse the web and prepare a router file for my component com_listing by using instruction on following link</p>
  
  <p><a href="http://forum.joomla.org/viewtopic.php?t=611587" rel="nofollow">http://forum.joomla.org/viewtopic.php?t=611587</a></p>
  
  <p>Here is my code of router file</p>
  
  <pre><code>function listingBuildRoute(&amp; $query)
  {
  
  
       $segments = array();
  
         if(isset($query['view']))
         {
                  $segments[] = $query['view'];
                  unset( $query['view'] );
         }
  
  
  
  
  
         if(isset($query['task']))
         {
                  $segments[] = $query['task'];
                  unset( $query['task'] );
         };
  
  
         if(isset($query['id']))
         {
                  $segments[] = $query['id'];
                  unset( $query['id'] );
         };
  
          if(isset($query['type']))
         {
                  $segments[] = $query['type'];
                  unset( $query['type'] );
         };
  
         return $segments;
  
  
  
  }
  
  function listingParseRoute($segments)
  {
  
  
     $vars = array();
         switch($segments[0])
         {
                 case 'accomodation':
                         $vars['view'] = 'accomodation';
                          $id = explode( ':', $segments[2] );
                         $vars['type'] = (int) $id[0];
                         break;
                 case 'entertainment':
                         $vars['view'] = 'entertainment';
                         $id = explode( ':', $segments[2] );
                         $vars['type'] = (int) $id[0];
                         break;
  
         }
  
  
          switch($segments[1])
         {
                 case 'listing':
                         $vars['task'] = 'listing';
                         $vars['task'] =$segments[1];
  
                         break;
                 case 'details':
                         $vars['task'] = 'details';
                         $vars['task'] =$segments[1];
  
                         break;
  
         }
  
  
         return $vars;
  
  
  
  
  }    
  </code></pre>
  
  <p>It is preparing the URL Successfully as say for a task "listing" and variable "type" the URl is</p>
  
  <pre><code>index.php/component/listing/entertainment/listing/11
  </code></pre>
  
  <p>but it is not actuly going in the task listing.It is just showing the view entertainment.I think parse route function is not calling properly But i am not reaching to the correct solution.Please Help</p>