How to render CMS page in view with v1.0?

edited August 2012 in Modules
Hello! I'm trying to get my head around rendering CMS content in a controller/view scenario (say, where you want to be able to control the "body" content in the admin, but also throw in other custom view content, eg a Home page) in v1.0 beta.

Here's where I got to, but I'm not sure if it's right:

class Home extends CI_Controller { function __construct() { parent::__construct(); } public function index() { $vars = $this->fuel->pagevars->retrieve('home'); $vars['controller_content'] = 'Some custom controller content'; // use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing $this->fuel->pages->render('home/index', $vars); } }

and in the view I just have

<div class="content clearfix"> <?php echo fuel_var('body', ''); ?> <ol><li><?php echo $controller_content; ?></li><li>Some custom view content</li></ol> </div>

I should explain, fuel_mode is set to 'auto', the default controller in routes.php is 'home' & there's the usual layout file that sandwiches all the above into html.

Is that what was intended by the version 1.0 way of doing things? If so it's a lot cleaner than what I was doing in v0.93 to achieve the same result.

Comments

  • edited 5:48PM
    That should do it.
  • edited August 2012
    Are there any further examples of what can be done with the Fuel_pages class?
  • edited 5:48PM
    Have you checked out the User Guide Module? That provides API documentation:
    https://github.com/daylightstudio/FUEL-CMS-User-Guide-Module
  • edited 5:48PM
    Yes, it's brief but tantalising.

    It looks like pages might be created via scripts rather than the admin, for example?

    I was wondering if there were any revised tutorials in the offing?
  • edited 5:48PM
    That is correct. You can use the following with TRUE as the last parameter to return it as a string value:
    $this->fuel->pages->render('home/index', $vars, array(), TRUE);

    With regards to revised tutorials, we have a few other things we are working on including a what's changed blogged post but do plan on talking about all the new changes.
Sign In or Register to comment.