I have a problem with "Pages & Variables"

I use CodeIgniter for different projects and found FUEL CMS. I am a beginner in FUEL CMS.

According to the instructions on the "Pages & Variables"
http://docs.getfuelcms.com/general/pages-variables
I created "Static Page - About"

After entering
http://localhost/cms_fuel_test/about /
the page was displayed.

So I created a page with "controller" - "about/contact" (controllers/About.php)

<?php

class About extends CI_Controller { 

  function __construct() 
  { 
    parent::__construct(); 
  } 

  function contact() 
  { 
    // set your variables 
    $vars = array('page_title' => 'Contact : My Website');

    $vars = array('test' => 'Testovací obsah ěščřžýáíéúů');

    //... form code goes here 
    $this->fuel->pages->render('about/contact', $vars); 
  } 

} 
?>

and _ wiew/about/contac.php_

<h1>CONTACT - Hello World</h1>
<p>This is our CONTACT page</p>
<p><?php echo $test; ?></p>
<img src="<?php echo $bigpic; ?>">

after entering
http://localhost/cms_fuel_test/about/contact
page display fine

I created "CMS Page - about/team" according to the instructions, but the page after the assignment
http://localhost/cms_fuel_test/about/team
it was a mistake "404 Page Not Found"

I tried to view the page
http://localhost/cms_fuel_test/about/contact
page display fine

I tried to view the page again
http://localhost/cms_fuel_test/about
but it did not dispaly anymore. It reported "404 Page Not Found"

I have in config/MY_fuel.php file

$ config ['fuel_mode'] = 'auto';

Could you give me an advice please? Where am I making mistake?

Thank you

Comments

  • By creating the "About" controller, you're effectively telling Fuel to now look in that controller for anything else that starts with the "about" url segment (previously there was no controller, so it just looked in Pages).
    If you want "./about/team", you need to add a function in about.php called "team"

  • I thought that when I set AUTO, the "view" will search for itself.

    This means that I can not have a combination of stand-alone views, views called "controller" and pages from the CMS database as described in "Pages & Variables".

    In "Pages & Variables" is combination

    • "about - static page" is a view
    • "about/contact - controller page" is a view called from "controller"
    • "about/team" is a CMS (database)
      I thought that it works together.

    Too bad. So it complicates the situation for me :(

  • The documentation may be a little old there. CI 3 complicated how FUEL got around that with hooks that so now when a controller is setup, it will take over regardless. So any view files would need to be rendered from the controller as well.

  • Please.
    How can I view content from a CMS database using a controller?
    I have a page created in CMS (location = about/team). How do I display it by calling from a controller?
    Thank you for your help

  • If this is the case

    <?php
    
    class About extends CI_Controller { 
    
      function __construct() 
      { 
        parent::__construct(); 
      } 
    
      function index() 
      { 
       $this->fuel->pages->render('about'); 
      } 
    
      function contact() 
      { 
        // set your variables 
        $vars = array('page_title' => 'Contact : My Website');
    
        $vars = array('test' => 'Testovací obsah ěščřžýáíéúů');
    
        //... form code goes here 
        $this->fuel->pages->render('about/contact', $vars); 
    
      } 
    
      function team() 
      { 
        $this->fuel->pages->render('about/team', array(), array('render_mode' => 'cms')); 
      } 
    
    } 
    

    thank you then

    Would be a good corrected instruction in "Pages & Variables", so that it does not mislead other beginners

Sign In or Register to comment.