EllisLab text mark
Advanced Search
     
Re-mapping URI segments when using sub-folders in /controllers
Posted: 01 September 2007 06:49 AM   [ Ignore ]
Avatar
Joined: 2006-05-07
270 posts

I’m using a sub-folder for my controllers, so I can do:

http://www.example.com/sub-folder/controller/method/id

However, this means that the id passed through above is in $this->uri->segment(4) instead of segment 3 where it normally would be.

Is there any way to either:

a) Re-map the URI segments so 4 is 3 and so on; or
b) Use the routes.php re-mapping rules to map requests onto controllers in sub-folders while retaining the correct numbering of URI segments?

smile

 Signature 

The Watchmaker Project | My EE add-ons | Follow me on Twitter

 
Posted: 01 September 2007 08:02 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-07-17
122 posts

i add parameters to the controllers methods.

function method($param='')
{
   
if ($param=='')
   
{
      
// the value isn't passed in the URI
   
}

and for an uri like
  /folder/controler/method/value
  od /controller/method/value

value gets passed to the function as $param

and i think this is a bullet proof method when using routs.php too!

 Signature 

Computers are incredibly fast, accurate and stupid. Human beings are incredibly slow, inaccurate and brilliant. Together they are powerful beyond imagination.

                                    A. Einstein

 
Posted: 01 September 2007 08:36 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-05-07
270 posts

Ah, excellent - I’d overlooked that way of retrieving parameters. Thanks. smile

 Signature 

The Watchmaker Project | My EE add-ons | Follow me on Twitter

 
Posted: 01 September 2007 01:57 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts

Also remember to take advantage of

echo $this->uri->router->directory;
echo 
$this->uri->router->class;
echo 
$this->uri->router->method
 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management