opt-in controller not opening page

I'm trying to debug a problem with my Fuel 1.4 build that is using the PHP7.2 compatibility branch. It's an upgrade of a working 1.3x site.

I have a controller called "myctl" which contains a bunch of methods. I also have a fuel page (in the database) with the location set to "myctl/foo". The controller and its methods work. However, visiting the page fails with a 404.

In the docs: http://docs.getfuelcms.com/general/opt-in-controllers, it says "The CodeIgniter Router is modified to route all requests that don't map to a controller method to a default controller named page_router". I take that to mean that Fuel will try the controller first and it can't find a method that fits, it will then go looking for a page instead.

This was the case when my site was v1.3. Something I've added to the 1.4 (PHP7.2) upgrade is now stopping this working.

Any suggestions on where to start looking?

Comments

  • This sounds like a change that was introduced with the upgrade from CI 2 to CI 3 in 1.4 and if you have a controller of myctl, any page with that URI segment will use that controller. If I remember correctly the reason, the CI hooks to make that happen didn't work anymore and required hacking the CodeIgniter core file which I didn't want to do. I actually have some updates to that documentation page that I haven't pushed yet. The fix for it, which admittedly isn't as nice as in 1.3, is to essentially create a foo method on your controller that returns the page from the CMS:

    $this->fuel->pages->render('myctl/foo',.....);
    
  • Thanks. That explains why I've been scratching my head looking for the code in the CI core files :)
    I've always worked to the principle you describe but this particular site started as a 1.0 site and it all just worked until my upgrade to 1.4.
    I got bored of trying to fix it and just renamed all instances of "myctl" in the page location fields.

  • edited June 2018

    I started trying to fix it by adding this to the myctl constructor if this helps anyone later...
    //page not method
    $uri = $this->uri->segments;
    if ((!empty($uri[2])) && (! in_array(strtolower($uri[2]), array_map('strtolower', get_class_methods($this))))){
    echo 'missing method:: '.print_r($uri[2],true);
    //do show page
    }
    exit;

Sign In or Register to comment.