1

I am developing custom component for joomla 3.x.

Our urls for non-sef views are not working url: index.php?option=com_mycomponent&view=myview2&id=mycustomeitemid

The same url when sef is enabled works perfectly working url: /index.php/component/com_mycomponent/myview2/mycustomeitemid

the issue is that the non sef url when clicked is redirecting to /index.php?option=com_mycomponent&view=myview1 myview1 is another view of the same component

below is my component router code

    <?php
  class MycomponentRouter extends JComponentRouterBase
  {

       public function build(&$query)
       {
           $segments = array();
           $view     = null;

           if (isset($query['task']))
           {
               $taskParts  = explode('.', $query['task']);
               $segments[] = implode('/', $taskParts);
               $view       = $taskParts[0];
               unset($query['task']);
           }

           if (isset($query['view']))
           {
               $segments[] = $query['view'];
               $view = $query['view'];

               unset($query['view']);
           }

           if (isset($query['id']))
           {
               if ($view !== null){
                   $segments[] = $query['id'];
               }else{
                   $segments[] = $query['id'];
               }

               unset($query['id']);
           }

           return $segments;
       }


       public function parse(&$segments)
       {
            $vars = array();

            $vars['view'] = array_shift($segments);
            $model = mycomponentHelpersNamespace::getModel($vars['view']);

           while (!empty($segments))
           {
                 $segment = array_pop($segments);
                 if (is_numeric($segment))
                 {
                    $vars['id'] = $segment;
                 }
                 else
                 {
                    $vars['task'] = $vars['view'] . '.' . $segment;
                 }
          }

          return $vars;
      }
}
?>

Basically i want to redirect a href link to view2 page with a unique itemid href non sef: index.php?option=com_mycomponent&view=myview2&id=mycustomeitemid.

thanks in advance.

regards

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.