Re: OT: CodeIgniter Routing

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: keith smith
Date:  
To: amit, Main PLUG discussion list
Subject: Re: OT: CodeIgniter Routing

I want to create separate CRUD controllers for each table.  If I use one controller to manage 30 or 40 tables I end up with a controller that would be thousands of lines long. 

I am following the M-V-C methodology built into Codeigniter.

I'm trying to figure out how to build the routing so that I can have :

/cp - menu and login

/cp/pages - CRUD controller for the pages table

/cp/users - CRUD controller for the users table

I will need to CRUD 30+ tables. 

Thank you for your help!
  

------------------------

Keith Smith

--- On Fri, 11/30/12, Amit Nepal <> wrote:

From: Amit Nepal <>
Subject: Re: OT: CodeIgniter Routing
To:
Date: Friday, November 30, 2012, 10:06 AM







    I avoid routes as much as possible.
      Controller alone can handle various functions and you don't really
      need to create multiple controllers for similar task. Helps keep
      it simple. 




      eg. if I were to have  CRUD operations on a page, i would create a
      page controller , which would then have various functions like
      add  , delete, update etc and the default (index) function in the
      controller would list stuffs.




      For database as Tom metioned, just use the model (eg.
      page_model.php , would have all the functions related to database
      ) ,  you can then load  page model in the page controller and do
      the CRUD operations.




      http://tutorialcodeigniter.com/beginners/welcome.html  ( This
      might be helpful too)






      Amit K Nepal


          Infrastructure Engineer (RHCE)


          omNovia Technologies Inc


          Amit K Nepal



      On 11/30/2012 9:53 AM, Tom Haws wrote:



    Yeah.  Keep researching CodeIgniter tutorials, because
      ideally, you wouldn't ever need to use routes.php unless you had a
      need for an alias or some other special occasion.




      On another note, it would be more conventional to talk to your
      database tables in model files and then call model functions in
      your controllers.  Again, I recall watching a short CodeIgniter
      tutorial video that really helped clarify this.




        --


        "To forgive is the highest, most beautiful form of love. In
        return, you will receive untold peace and happiness." - Dr.
        Robert Muller






        On Fri, Nov 30, 2012 at 9:36 AM, Eric
          Cope <>
          wrote:



            You can just put your controller "pages" in the
            controller/cp directory...




            Then you don't have to muck with the routes...




            Eric







                  On Fri, Nov 30, 2012 at 9:20 AM, keith
                    smith <>
                    wrote:














                              Hi,




                              I'm rather new to CodeIgniter.  I'm using
                              version 2.0.3 and am using the provided
                              .htaccess code to remove index.php from
                              the URL.  




                              I'm working on a control panel and would
                              like to set up a controller for each table
                              to keep things simple and modular.  (any
                              feedback on a better idea is much
                              appreciated)




                              I was thinking I needed to configure the
                              controllers this way




                              1) $route['cp/pages/(:any)'] = "cp_pages";
                              (would contain only controller code for
                              managing the pages table.)




                              2) $route['cp/users/(:any)'] = "cp_users";
                              (would contain only controller code for
                              managing the users table.)




                              .... other table configured with their own
                              control panel.




                              3) $route['cp/'] = "cp"; (splash page and
                              menu.  If not logged in presents the log
                              in form)




                              /cp/  gives me the splash page. so far so
                              good.




                              /cp/pages - cp controller - not what I was
                              expecting.  I was wanting the index
                              function of the cp_pages controler.




                              /cp/pages/list/ - takes me to the cp_pages
                              controller / index function




                              What I would like to configure is:




                              /cp/ - use cp controller




                              /cp/pages/ - use the cp_pages controller /
                              index function


                              /cp/pages/add/ - use the cp_pages
                              controller / add function 


                              /cp/pages/list - use the cp_pages
                              controller /list function


                              /cp/pages/list/10 - use the cp_pages
                              controller /list function with segment set
                              to 10 as starting point.




                              If I'm going down the wrong path please
                              let me know.




                              Thank you!  






                              ------------------------


                              Keith Smith








                  ---------------------------------------------------


                  PLUG-discuss mailing list - 


                  To subscribe, unsubscribe, or to change your mail
                  settings:


                  http://lists.phxlinux.org/mailman/listinfo/plug-discuss









            ---------------------------------------------------


            PLUG-discuss mailing list - 


            To subscribe, unsubscribe, or to change your mail settings:


            http://lists.phxlinux.org/mailman/listinfo/plug-discuss












      ---------------------------------------------------
PLUG-discuss mailing list - 
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss







-----Inline Attachment Follows-----

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss