Welcome Guest, Not a member yet? Register   Sign In
Controller question
#1

[eluser]Assim[/eluser]
Let's say I wanted to create controller like this:
http://example.com/pages to load page list
http://example.com/pages/something to load "something"

Well here's the code that I wrote, I'm using the remap function and taking $PageSlug as the second URI segement. In the above example, "something" was the $PageSlug
Code:
<?php

class Pages extends Controller {

    function Pages()
    {
        parent::Controller();

        // Load language file
        $this->lang->load('website');
    }
    
    function _remap($PageSlug)
    {
        if(!$PageSlug) {
            // Load page list if no page supplied in URI
            // http://example.com/pages
        }
        else
        {
            // Load a page according to page slug
            // http://example.com/pages/something
        }
    }
}

/* End of file pages.php */
/* Location: ./system/application/controllers/pages.php */

In the if statement, I can only load the page and not the page list.

I tried writing it in the following ways:
if(!$PageSlug)
if(empty($PageSlug))
if($PageSlug = '')

But still I can't load the page list which is when the $PageSlug is not provided. Does anybody have the solution to this problem?


Messages In This Thread
Controller question - by El Forum - 02-21-2010, 12:51 PM
Controller question - by El Forum - 02-21-2010, 01:45 PM
Controller question - by El Forum - 02-21-2010, 01:51 PM
Controller question - by El Forum - 02-21-2010, 02:13 PM
Controller question - by El Forum - 02-22-2010, 02:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB