Fuel bar inline edit buttons and controllers with CMS content

edited February 2013 in Installation
I've been creating controllers and views (eg home page, news events etc) that pull in CMS content if the CMS page of the same name exists - so if "news" exists at "/news" and there is a controller of the same name, I fetch CMS and add it to the variables that make the view. That way I get say, a news module listing, and optionally, CMS content above it.

In v1.0 I use $this->fuel->pagevars->retrieve($this->uri->uri_string()) to get the CMS content (in MY_Controller), merge any controller content in with the CMS layout array, and use $this->fuel->pages->render($view, $all_vars) where $all_vars is the merge of layout variables and custom content.

When rendered in the view, and you are logged in as admin, the Fuel bar inline editor menu appears, but the edit links are not displayed, neither are the pencil icons against the content (eg page_title, body), although the view uses fuel_var() to fetch "page_title" and "body".

What could I do to make the inline editing function? The fuel_var() methods place the __fuel_marker__ spans in the right place, so I suppose some JQuery trigger is not firing.


  • edited 7:01AM
    Is the pencil clicked in the inline edit bar?
  • edited February 2013
    No the Fuel bar is just "back to admin" and "logout".

    I'll spell out what I'm doing a bit more. In MY_Controller I have a method renderCMS():
    /* * Merges controller vars with CMS vars and renders page */ function renderCMS($view, $controller_vars = array()) { // default to home page content (if any) $page_vars = ($this->uri->uri_string() != '') ? $this->fuel->pagevars->retrieve($this->uri->uri_string()) : $this->fuel->pagevars->retrieve('home'); $all_vars = array_merge($page_vars, $controller_vars); $this->fuel->pages->render($view, $all_vars); }

    and then in a controller (extended from MY_Controller) I will use:

    $vars = array(); $vars['some_custom_content'] = $this->some_model->some_method(); $this->renderCMS('home/index', $vars);
    so the render() method will then fetch and merge CMS content with any custom controller stuff. This all works nicely, but when fuel_var() is used to echo out "body", the span elements (__fuel_marker__) appear in the right place, but the fuel bar isn't responding to the content available. I'm trying to work out what triggers the pencil and other edit functions. Then I'd be really happy!

    Something is present for the CMS controller that isn't for MY_Controller?
  • edited 7:01AM
    Try adding the following:
    $this->fuel->pages->render($view, $all_vars, array('render_mode' => 'cms'));
  • edited 7:01AM
    Yep that works - I'd forgotten about that - it's a property that's transposed from v0.93, in a way?

    Incidentally the User Guide doesn't list the value "cms".

    Thank you, that's actually a big step forward for my use of FUEL v1.
  • edited 7:01AM
    I've added a little more info about that on both the Fuel_pages::render class documentation and the comment about the "render_mode" property.
  • edited February 2013
    Something of interest I've noticed by using that render_mode property is that it affects the way the view (as I'm currently using it) is rendered.

    In the code examples above, I'm loading a view that has the home page layout eg (in a simplified way):
    <?php // Kill default layout by setting the value to empty fuel_set_var('layout', ''); $this->load->view('_blocks/header'); ?> <h1><?php echo fuel_var('page_title'); ?></h1> <?php echo fuel_var('body'); ?> <?php $this->load->view('_blocks/footer'); ?>

    However, with render_mode => 'cms' the content loaded in _blocks is removed completely. Is that correct?. I suppose that's what 'cms' means - just render the db contents at this url !?

    To get round this I now have a layout file that in effect does the job of the view. So for the page 'home' in the CMS I can set layout as 'home' (ie from the views/_layouts folder), and now the HTML for the home page is rendered along with the CMS, AND any content from the controller 'home' - provided the layout array is specified in MY_fuel_layouts!

    I tend to make most custom controllers allow CMS content to be added, so now I'm looking at a different way of working, where custom 'views' now become custom 'layouts' in the _layouts folder, and for each there is an entry in MY_fuel_layouts to allow the admin CMS to show fields for that layout file. It's the price to pay though to allow inline editing to work properly.

    I suppose the controller $this->fuel->pages->render() method should now not load the view file ('home/index'), but instead specify the url location 'home'? In fact, if the 1st argument contains a '/' it must imply a file path, and therefore a view.
  • edited 7:01AM
    This is at a tangent, but I've noticed that there is a line in fuel_pagevariables_model, in the _common_query method, that adds published = 'yes' if the call is not from the admin, and where honor_page_status is true, but I can't see when honor_page_status is ever set to true?

    I've noticed this as controller+cms pages don't seem to respect published status, unless honor_page_status is true.
  • edited 7:01AM
    What you explained above is correct. You need to create layout files which include the header and footer because the CMS is only capturing the "body" variable content.

    For the publish status, I've just pushed change to add "vars_honor_page_status" like so:
    $this->fuel->pages->render($view, $all_vars, array('render_mode' => 'cms', 'vars_honor_page_status' => TRUE));
  • edited February 2013
    That didn't quite achieve what I was expecting.

    The Fuel bar will recognise the page is not published, but the CMS content is still visible when you are not logged in.

    What I've done now is use
    to test for the published status, as find() honours the status, so if the return from that is empty, I know I should 404 instead.

    So to summarise, inline editing is only possible with with mixed source content (ie CMS + controller content and or variables content) IF a separate layout file is used.

    I can live with that! Thanks again! Is version 1 for release soon?

    I've tried to express all this in my blog: http://adventuresincms.blogspot.co.uk/2013/02/the-ins-and-outs-of-inline-editing-in.html
  • edited 7:01AM
    I understand now. I just pushed a fix to make the only_published parameter public which means you can set it in the 3rd parameter of the render method.

    With regards to version 1, we are hoping to release it soon but I've been saying that for a while. Internally, Daylight uses it exclusively for all new projects. However, we have a few things related to FUEL we want to do first.
  • edited 7:01AM
    Great - I'll give that a go soon. Thank you.
Sign In or Register to comment.