Welcome Guest, Not a member yet? Register   Sign In
Subdirectory Controller Problem

[eluser]Kyle Wiebers[/eluser]
I'm building my first website with CodeIgniter and it's very easy so far. However I want to create a url like localhost/MU/events/rooms/roomname, where roomname changes with the room the user selects. I have a function rooms in the events controller that takes an argument, but when trying to access the main page, localhost/MU/events/rooms CI throws an error that I was missing an argument.

My code looks like this:
function rooms($room)
        if(isset($room)) {
            switch($room) {
                case 'name':
                    $data['content'] = '<p>Room Name</p>';
        } else {
            $data['content'] = '<p>Test</p>';

Is there anyway to eliminate the error on the page?

instead of using isset I would prefer $this->uri->segment(n) where n is the number of the uri segment. This contains the value if it exists of false if nothing is specified.

You have to load the uri class.


[eluser]Rick Jolly[/eluser]
function rooms($room = false) {

[eluser]Kyle Wiebers[/eluser]
Thanks for the help. I love the CodeIgniter base, it is by far the easiest and best supported framework I've ever used.

Theme © iAndrew 2016 - Forum software by © MyBB