Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorasejua
    • CommentTimeDec 18th 2007
     

    Hi again,

    Being honest, don't know if I've understood right the route theory. Will try to explain what I'm trying to do.

    Let's have a table "sites" and a table "devices". Device belongs to site and Site has many devices. I've added a new action called filter and a link in the site's listing view called 'details' that will carry me to the filtered list of devices that belongs to that site. The link would look like /device/filter/site/4 (4 would be the site's id I want to look)

    My route file is like this:

    $Map->connect('/:controller/:action/:filterby/:filterid', array(
    'controller' => 'page',
    'action' => 'index',
    ));
    $Map->connect('/:controller/:action/:id', array(
    'controller' => 'page',
    'action' => 'index'
    ));
    $Map->connect('/', array(
    'controller' => 'page',
    'action' => 'index'
    ));
    

    It works, but the other urls, like for example the listing view ones, that should be

     /site/show/1
    

    have changed to

     /site/show/?id=1
    

    Obviously seems I've conflicts with the routes, I'm very confused with the route thing ^^'

    Any ideas of how to solve it? Thanks in advance.

    • CommentAuthorKaste
    • CommentTimeDec 18th 2007
     

    Router can be a bit tricky.

    /device/filter/site/4

    your suggestion $Map->connect('/:controller/:action/:filterby/:filterid', array( 'controller' => 'page', 'action' => 'index', ));

    matches all and everything.

    This should guide you:

    $Map->connect('/device/filter/:filterby/:filterid', array( 'controller' => 'device', 'action' => 'filter' ));

    • CommentAuthorasejua
    • CommentTimeDec 19th 2007
     

    Seems to work nice ^^ So if device would have many ports and port would belong to device, to make the same thing in the device listing table I should add in route.php this also

    $Map->connect('/port/filter/:filterby/:filterid', array( 
    'controller' => 'port', 
    'action' => 'filter' 
    ));
    
    $Map->connect('/device/filter/:filterby/:filterid', array(
    ...
    

    Btw, how do I tell the url_helper class link_to function to place a static text within the url? Should I use another function or place it "manually"? The API documentation for that class is not found :P

    Thanks again Kaste

Add your comments
    Username Password
  • Format comments as