Using Dwoo/Smarty to render view files from controller

edited March 2012 in Modules
I want to be able to Display view files from the controller and so far I'm using this:
$this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'test')); $this->fuel_page->add_variables($data); $this->fuel_page->render();

But this way Dwoo doesn't process syntax from the view file like: {site_url('/my/path/')}
Dwoo works fine when I create pages from the admin dashboard, but I need to do the same with view files.

What do I need to do to enable parsing and use Smarty syntax for the view files?
Also is it possible to change the parsing from the pages created in the admin dashboard to Smarty?

PS. I'm considering to move to Dwoo templating but for now I need Smarty syntax.

Comments

  • edited 7:33AM
    You can pass a variable to your view file of 'parse_view' = TRUE like so:
    $data['parse_view'] = TRUE; $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'test')); $this->fuel_page->add_variables($data); $this->fuel_page->render();
    Alternatively, there is a "parse_template_syntax" function you can use on the rendered output:
    http://www.getfuelcms.com/user_guide/helpers/my_string_helper
    $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'test')); $this->fuel_page->add_variables($data); $output = $this->fuel_page->render(); $output = parse_template_syntax($output); echo $output;
    Dwoo should support the Smarty syntax to some extent.
    http://wiki.dwoo.org/index.php/SmartySupport
  • edited 7:33AM
    Thanks for the help. I will try it tomorrow.
  • edited 7:33AM
    The first solution works great and Dwoo has great Smarty support. But now my layout pages are not parsed, only my views are.
    My idea was to use this inside the main layout page to parse the blocks and everything else:
    parse_template_syntax($this->load->view('_blocks/header'),$data);
    However, I ran into 2 problems.
    1. the parse_template_syntax doesn't actually parse the block.
    2. Not sure if I need to pass variables to the view again like when using parse_template_syntax but if I do I would need to reconstruct the $data array

    What do you suggest I do?

    PS. is there a list of the variables I can pass to a view to configure it?
    like these: $data['parse_view'] = TRUE; $data['layout'] = "my_layout";
  • edited 7:33AM
    The first solution will just parse the view like you said. For your second solution, I believe the issue is because you are not returning it as a string. Try this:
    parse_template_syntax($this->load->view('_blocks/header', $vars, TRUE),$data);
    There is a list of some of the variables at the bottom of this page:
    http://www.getfuelcms.com/user_guide/general/opt-in-controllers
  • edited 7:33AM
    Thanks that solved it.
    I never payed attention to the "Special Variables" in the opt-in-controllers page, but now I understand.
Sign In or Register to comment.