Part of the EllisLab Network
   
2 of 2
2
I’m at a standstill….need help with controllers (theory)
Posted: 06 September 2008 01:07 PM   [ Ignore ]   [ # 16 ]  
Research Assistant
RankRankRank
Total Posts:  412
Joined  05-30-2008

ontguy, I don’t know what Colin does… but that is basically a good way to group it.

In your controller it could be something like

<?php

class Bike extends Controller {

  
function Bike()
  
{
    parent
::Controller();
    
$this->load->helper('url');
  
}

  
function add()
  
{
    $this
->load->view('bike/add');
  
}

}

That’s a basic example of how I would do it.

Profile
 
 
Posted: 06 September 2008 02:57 PM   [ Ignore ]   [ # 17 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

I just have a single sub-folder in views like:

app/views/bike/bike_form.php
app/views/bike/part_form.php
app/views/bike/manufacturer_form.php
app/views/bike/bike.php
app/views/bike/part.php
...

And those are just fragments of the final pages that are rendered.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 06 September 2008 03:13 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
RankRank
Total Posts:  130
Joined  04-24-2007

I gave this structure a try:

app/controllers/bike.php
app/controllers/bike/part.php

When I go to URL/bike/part
it gives me a “404 Page Not Found”

When I removed the file bike.php, it works.

Did any changes need to made to CI through extensions or otherwise for this to work?

 Signature 

CI Bookmarks

Profile
 
 
Posted: 06 September 2008 03:22 PM   [ Ignore ]   [ # 19 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

Huh.. you’re right, ontguy. Guess we’ll need to use routes for this or rethink the structure. That’s frustrating, but it makes sense. Otherwise, CI would find bike.php and think “okay, lemme instantiate this Bike class,” then when it inevitably doesn’t find the “part” function, it would have to start over and look for a ‘bike/part.php’ file, and continue on. Guess that’s not such a stretch, but it’s obvious to see that this is not what’s happening.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 06 September 2008 04:02 PM   [ Ignore ]   [ # 20 ]  
Lab Assistant
RankRank
Total Posts:  130
Joined  04-24-2007

I’m glad it does the same for you smile
Good to know I’m going crazy.

A workaround to this maybe to extended Router.php (_validate_request) and have it check for the directory first then the file (I tried it and it doesn’t seem to work; the controller in the directory works but the controller doesn’t).

I found this in my search, the file directory name issue comes up in this thread: http://codeigniter.com/forums/viewthread/46120/

 Signature 

CI Bookmarks

Profile
 
 
   
2 of 2
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120466 Total Logged-in Users: 33
Total Topics: 126545 Total Anonymous Users: 4
Total Replies: 665388 Total Guests: 305
Total Posts: 791933    
Members ( View Memberlist )
Newest Members:  DistrikerGerd Pansenneilgroomart.maniaakoloans5kmotion1jelevinlizandermagnosismx2428