fuel_var not working when calling a page from controller

I have a page _layouts/terms. I created the corresponding page from admin and added some content to it. I am trying to load it from a controller the following way

$this->data['content']='_layouts/terms';
$this->data['username']=$this->session->userdata('username');
$this->load->view('_layouts/main', $this->data);

In the terms.php I have specified the fuel variable
echo fuel_var('body', '');

The text I entered through admin is not there when accessed through controller. But during preview, it comes with added content. Is there anything I am missing here.

Comments

  • edited 6:57AM
    This sounds like you are trying to render a page created in the CMS witha a controller correct? If so, this may help explain how to do that:
    http://www.getfuelcms.com/user_guide/general/creating-pages#controller
  • edited September 2012
    When I render the page this way, I am logged out of my account and shows the page with CMS data. (I use ion_auth for login managing users). I would like to display the required pages without a logout. For other areas, where there is no CMS data is required to be displayed, I write the code in the view itself accessing model to fetch data and able to display the pages without a logout.

    I am wondering whether I can implement the pagevariables_model that way in my view to directly access the CMS data. Please let me know if it is possible?
  • edited September 2012
    Ok, I finally got it working extending pagevariables model to create a model and using that, I am able to assign the content in the view itself. Please let me know how can I set a fuel var from the view? I am trying to set keywords and meta from my view
  • edited 6:57AM
    Does fuel_set_var() work for you?
    fuel_set_var('my_var', 'my_value')
Sign In or Register to comment.