Create CMS pages through a custom module

edited April 2015 in Modules
I extended fuel_page_model and my purpose is to create CMS pages through my application and the pages should be accessible in front. I am going to use the existing tables related to pages. The fields which I am interested in are: values for page_title and body and active. I don't understand how pages work in FUelCMS eve after I read some documentation.
I need to create a page (not as fuel admin) and then to access it through a link where I should see the content from WYSIWYG.
I am not sure if it is clear what I meant here, but I can explain what I did so far.

Comments

  • edited April 2015
    There are 2 tables used for the data behind a page. The fuel_pages and the fuel_pagevariables. The fuel_pages table saves the location value (e.g. about/history), as well as it's cache and published settings. The fuel_pagevariables table is where all the page variables are saved.

    You can use the fuel_pages_model and the fuel_pagevariables_model respectively to access their data. The fuel_pages_model can return a page record which has a reference to the variables like so:
    $this->load->module_model(FUEL_FOLDER, 'fuel_pagevariables_model'); $page = $this->fuel_pages_model->find_by_location('about/history'); foreach($page->variables as $var){ echo $var->name; }
  • edited 6:21AM
    I know about those two models..I extended from the there. I don't understand how things work regarding accessing a page. How should I know what location to use? I don't want that client sets a location because he doesn't know what it means. Also, as far as understand, for your example I need to have a controller named about and a function history. This isn't a solution for me.
    What location should I set in order to be able to access all the CMS pages? Or how should all these things work for the client?
    Am I missing something here?
  • edited 6:21AM
    I'm not quite sure I completely understand your trying to do but will give it a shot in terms of how FUEL finds CMS pages. First it will look at the routes and then if there is a controller/method in place it will use that. If no controller is found, it will go to the 404_override controller which is located in fuel/modules/fuel/controllers/page_router.php. This will first look for a page in the CMS that has a location value that matches the current URI. If nothing is found in the CMS, it will look for a view file with that path. If no view file is found it will look in the redirects config file for a passive redirect and then finally deliver a 404 error.
Sign In or Register to comment.