joomla - Issue with router.php and send parameters via URL in joomla3 component -


i designed joomla3 component...

i want send parameters component via url.

i linked menu component..so access component address:

http://examle.com/tag

i have 3 parameters:

years

month

day

example: http://examle.com/tag/2014/12/19

this router.php

<?php defined('_jexec') or die ; function bahaedinibuildroute(&$query) {        $segments = array();        $app     = jfactory::getapplication();        $menu        = $app->getmenu();        $params      = jcomponenthelper::getparams('com_bahaedini');        $advanced    = $params->get('sef_advanced_link', 0);          if(isset($query['year']))        {                 $segments[] = $query['year'];                 unset( $query['year'] );        }        if(isset($query['month']))        {                 $segments[] = $query['month'];                 unset( $query['month'] );        }        if(isset($query['day']))        {                 $segments[] = $query['day'];                 unset( $query['day'] );        }          return $segments; }   function bahaediniparseroute($segments) {        $vars = array();         $segments[0]='items';        switch($segments[0])        {                 case 'items':                        $vars['view'] = 'items';                        if(isset($segments[0]))                        {                        $year = explode( '/', $segments[0] );                        $vars['year'] =  (int)$year[0];                        }                         if(isset($segments[1]))                        {                        $month = explode( '/', $segments[1] );                        $vars['month'] = (int)$month[0];                         }                         if(isset($segments[2]))                        {                        $day = explode( '/', $segments[2] );                        $vars['day'] = (int)$day[0];                         }                           break;                                                                        }        return $vars; }?> 

so wana test it. put code in php file in models folder (items.php):

echo "<br>y:".$_date          = urldecode($app->input->getstring('year')); echo "<br>m:".$_date          = urldecode($app->input->getstring('month')); echo "<br>d:".$_date          = urldecode($app->input->getstring('day')); 

the result are:

y:0 m:12 d:19 

you can sea...value of 'y' must '2014' '0'!

how can solved problem? wrong?

reading code, bahaediniparseroute() function, first assign $segments[0] 'items', try explode , read $year it... it's returning '0' because you're casting $year int, contains 'items'.

try removing casts , var_dump($segments) before assign 'items' (which makes little sense anyways, why set , test in conditional loop? know $segments[0]='items' what's point of switch ... case 'items'?


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -