Opt-in Controller -> CMS view (Version 1.0 beta)

edited October 2012 in Share
Hi,

I'm trying to setup a Controller for my contact page, while using the CMS. So in my CMS Page I have: {$form} where I want the form to be placed (as I used previously in 0.93)

In my controller I have:
class Contact extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->library('form_builder'); /* Form builder content */ $vars['form'] = $this->form_builder->render(); $this->fuel->pages->render('Contact', $vars); } }

The last 2 lines on 0.93 looked like:
$page_init = array('location' => 'contact', 'render_mode' => 'cms'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render();

And that worked. What's the proper procedure to make version 1.0 do the same thing now?

Thanks

Comments

  • edited October 2012
    There's a third parameter you can use on the render method to pass in the render_mode value:
    $this->fuel->pages->render('Contact', $vars, array('render_mode' => 'cms'));
  • edited 11:38AM
    Awesome, that worked perfectly.

    I was trying to find that in the documentation, not sure if I overlooked it or not but I appreciate your help.

    Thanks!
  • edited 11:38AM
    No problem. The documentation is under the Fuel Pages Class in the 1.0 user guide. If you don't have the 1.0 user guide, you can download it on GitHub here and install it as a module in your FUEL installation:
    https://github.com/daylightstudio/FUEL-CMS-User-Guide-Module

    We will be working on getting that documentation on a public server so you don't have to download it as we get closer to rolling 1.0 out.
  • edited October 2012
    Next question, something changed with sessions or dwoo or variable passing:

    I used to be able to check {$session->flashdata} in the CMS but it's throwing an error now.

    This after setting the flashdata and redirecting back to the page:

    $this->session->set_flashdata('success', TRUE); redirect('contact');

    It gives the following error:
    Severity: Notice Message: Undefined property: CI_Session::$flashdata Filename: dwoo/Dwoo.php

    Any ideas?
    Thanks :)
  • edited 11:38AM
    What line number does that reference? And I'm assuming the session library is loaded? Also, there is a "session_flashdata" function you can use instead along with a "session_userdata" helper function new to 1.0.
  • edited 11:38AM
    Sorry, line 1217.
    Yes, the session library is loaded with: $this->load->library('session');

    is session_flashdata() used to set the session or retrieve the session?
  • edited 11:38AM
    It's used to retrieve.

    With regards to it working before and not now, I'm not sure. I just tested it out locally and it seemed to work OK. Did you try clearing out the compiled files?

    Also, can you check in the fuel/application/config/parser.php file that the session is included in the "parser_assign_refs" config paramater. Those should be assigned on line 246 in the MY_parser.php file.
  • edited 11:38AM
    Actually, I think it might have something to do with this link:
    http://www.getfuelcms.com/forums/discussion/949/table-markup-is-mangled-after-save/p1

    As I noticed the code I paste:
    {if ($session->flashdata('success')) }
    gets changed to
    {if $session->flashdata 'success' }</code without the parentheses. In the link you mention adding a line to My_fuel_modules.php but how would I add that to the Pages module which is built in?
  • edited 11:38AM
    Okay, so I found MY_fuel_modules.php in: \fuel\modules\fuel\views\_generate\simple\

    and added the line: 'sanitize_input' => array('template','php'),

    But I still seem to have that same issue.
  • edited 11:38AM
    Try adding the following to your MY_fuel_modules.php which overwrites existing module data:

    $config['module_overwrites']['pages'] = array('sanitize_input' => array('template','php'));
  • edited 11:38AM
    BTW... the problem I'm guessing is due to line 262 in the MY_string_helper under the php_to_template_syntax function.
  • edited 11:38AM
    One workaround at the moment may be to set the $session->flashdata('success') to a variable and then use that in the if condition.
  • edited 11:38AM
    I tried adding that line, but it didn't help. I agree with My_string_helper being an issue with that particular issue.

    So, another new odd thing, my filenames when added to the DB are being changed to omit the . Is that supposed to happen?

    ie test.jpg becomes testjpg in the DB.

    This seems strange. I did notice another thread that talks about using 'sanitize_images' => FALSE in the module config, but that didn't work either.
  • edited 11:38AM
    Okay, that's just odd. The files are being saved with the extension merged as their name:
    so file 1.jpg would go into the db as 1jpg but saved as 1jpg.jpg

    This is all I have in the module to modify the form to save the files:
    $fields['item'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE);
  • edited 11:38AM
    That's indeed a bug. I just pushed a fix to the 1.0 branch:
    https://github.com/daylightstudio/FUEL-CMS/commit/0d6d6d201ebf0b4107d5b1296522f0163397334e

    Thanks for the report
  • edited October 2012
    Strange, in order for me to have the file name stay the same in the DB I had to add the following function to my module:
    function on_before_save($where) { $where['item'] = $_FILES['item']['name']; return ($where); }

    otherwise it saved without the period.
    But that'll do I suppose.
  • edited 11:38AM
    It looks like that previous fix was only in one area. I've pushed a fix to implement it in the area where it sets the value and saves to the database as well. Thanks for the report.
  • edited 11:38AM
    That worked. Thanks! :)
    (thought I was losing my mind!)
Sign In or Register to comment.