Welcome Guest, Not a member yet? Register   Sign In
How to load view if function not exists?
#4

[eluser]jedd[/eluser]
[quote author="codeworxx" date="1257215469"]Hey Guys,
Now the View is not loaded (Error 404), because CodeIgniter is looking for the function 'systems', but "Systems" is the Category which i am looking for in the Database to create the View. So where's my Mistake?
[/quote]

My opinion (!) is that you should change your controller and method name to reflect the URL you are happy with. While I acknowledge that you can route around all kinds of mess, and no offence is intended here -- if you have to ask how to do this, then for the moment you should probably be adopting the simplest approach available.

So, rather than trying to use this url: index.php/category/systems to get to this method: Controller / Listings ... I'd suggest you do the following:

Try to think of your controller names as nouns, and your method names as verbs. That is, the controller handles a resource - a thing if you prefer - and your methods handle stuff you can do with those resources. Hence you might have a Listing controller with methods like 'show', 'edit', 'delete'.

Don't put much in your constructor at all at this stage (as you've got here) as it will just confuse you. Similar you probably want to leave the index() method almost empty - perhaps a simple _remap() or redirect() to your default / preferred method.

Don't use segment() calls unless you really need to - instead, for this kind of thing, you use the parameter feature for controller functions - a really feeble example follows:

Code:
// Somewhere in your Category controller

function  systems  ( $thing )  {
    // do some sanity tests on the content of $thing, and if okay ...
    $data['sane_thing']  = $thing;
    $this->load->view( 'category', $data );
    }


Messages In This Thread
How to load view if function not exists? - by El Forum - 11-02-2009, 02:31 PM
How to load view if function not exists? - by El Forum - 11-02-2009, 03:58 PM
How to load view if function not exists? - by El Forum - 11-02-2009, 04:05 PM
How to load view if function not exists? - by El Forum - 11-02-2009, 04:32 PM
How to load view if function not exists? - by El Forum - 11-04-2009, 06:49 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 09:24 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 09:45 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 10:08 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 10:23 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 10:38 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 10:50 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 10:55 AM
How to load view if function not exists? - by El Forum - 11-04-2009, 06:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB