How to find pages by id

edited March 2014 in Modules
Is there any way to find page by id in layout file. I'm currently using $this->fuel->pages->find(5).
But its not working. I'm getting following error message

Plugin module can not be found, maybe you forgot to bind it if it's a custom plugin ?

Comments

  • edited March 2014
    The "find" method should return a page record object. What are you doing with the page record object after you retrieve it?

    Running the following should get you the properties you can access:
    $page = $this->fuel->pages->find(5); echo '<pre>'; print_r($page->values()); echo '</pre>';
  • edited 5:10AM
    Thanks. I was tried to print_r the $page variable. But how can I get the layout variable for specific page and what are the other function that carried with $page object
  • edited 5:10AM
    It creates a data record class from the fuel_pages table. Below is the documentation as to where to find Data_record class information:
    http://docs.getfuelcms.com/libraries/my_model#data_record

    Specifically, it is a Fuel_page_model data record which extends the Base_module_record class -> Data_record.
  • edited 5:10AM
    Ok, now I get some outputs, but how do I get layout variables, I mean If I have some custom data field like meta, body and so on
  • edited 5:10AM
    You can use the Fuel_pagevars class like so:
    $vars = $this->fuel->pagevars->retrieve('my_location');

    You can get the current locations variables like so:
    $vars = $this->fuel->page->variables();
Sign In or Register to comment.