CodeIgniter Forums
why can't I send a uri segment to my index function ?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: why can't I send a uri segment to my index function ?? (/showthread.php?tid=23206)



why can't I send a uri segment to my index function ?? - El Forum - 10-03-2009

[eluser]seanloving[/eluser]
I wish this was possible but I get Page Not Found whenever I try to request a URL such as site.com/page/somepage

Code:
class Page extends Controller {

    function Page()
    {
        parent::Controller();
    }

    function index( $pagerequest )
    {
        // do stuff
    }
}


Where do I dig to figure out why this won't work?

Thanks

--Sean Loving


why can't I send a uri segment to my index function ?? - El Forum - 10-03-2009

[eluser]joeizang[/eluser]
dude,

from your link example and sample controller, you must have a function called somepage for it to be available in your url. the function should call a view if you so desire or you can use a template depending on prefrence


why can't I send a uri segment to my index function ?? - El Forum - 10-03-2009

[eluser]seanloving[/eluser]
[quote author="joeizang" date="1254629856"]dude,

from your link example and sample controller, you must have a function called somepage for it to be available in your url. the function should call a view if you so desire or you can use a template depending on prefrence[/quote]

I understand and use the standard convention, but I'm trying to make this work:

If there are no other methods in the Page class then I want the last segment (e.g. 'somepage') to be used as the $pagerequest parameter of the index function. My goal is to manually route an incoming $pagerequest whose name is arbitrary and thus not necessarily known by my Page controller a priori.

Basically I'll call the view within where I say // do stuff

-SL


why can't I send a uri segment to my index function ?? - El Forum - 10-03-2009

[eluser]Colin Williams[/eluser]
Use a _remap() method in your controller. Check the Controller page in the User Guide for details


why can't I send a uri segment to my index function ?? - El Forum - 10-04-2009

[eluser]seanloving[/eluser]
Thanks Colin - that's what I was looking for.