how to create editable page with module?

edited March 2011 in Modules
I'm familier with Codeigniter. When I create normally a page I make a Controller, a model and a view. Now I would like to have a home page where I can edit it's content in the CMS in the page section. Also I would like to have the last three news items. I don't know how to do this with Fuel cms.

Can someone help me with this?

Comments

  • edited 3:43PM
    You can login to FUEL, click on the Pages menu item on the left and create a page with the location value of "home" which is the default location name for the homepage. Alternatively, you can create a static view file named 'home' in your views directory and upload it to that same location within FUEL (pages in FUEL take precedence over static view files).

    For the last 3 news items, I would create a simple module that's linked to your news table. If you are using a static view file, you can use the fuel_model function or you could load the model like normal in CI. There's a few resources on the user guide that should be able to help you too (see below):

    http://www.getfuelcms.com/user_guide/general/creating-pages
    http://www.getfuelcms.com/user_guide/modules/simple
    http://www.getfuelcms.com/user_guide/modules/tutorial
    http://www.getfuelcms.com/user_guide/helpers/fuel_helper
  • edited 3:43PM
    ok thanks.

    And when I'm using a dynamic view in the CMS, how can I add the module to the page?
  • edited 3:43PM
    You'll need to use the Dwoo templating syntax and problem will want to use the fuel_model() function to get the data (e.g. {fuel_model('my_model', array('where' = 'published = "yes"')} ). The easiest way to do this would probably create the logic in a static file and then import the view. Importing does a lot of the translation for you on import.
    http://www.getfuelcms.com/user_guide/parsing
  • edited April 2011
    Ok thanks that's working now. I'm curious if it's possible to edit the content of the home page in the CMS and loading te news module with the home controller. I don't like to have PHP in my CMS page because the client wont understand the code and it's possible he will break the code.

    So I want to have those 2 separate that the client only can change the content of the site.

    Is this possible and how will I do this?
  • edited 3:43PM
    I think what you want is possible, but so that I'm clear, do you want the news items only editable on the homepage? Or is there a body section on the site you only want editable for the client? Or both?
  • edited 3:43PM
    No, On the home page I've a block text en underneath the news items. I'm talking about this website: http://st-evenementen.nl/

    I would like to edit the body text in the CMS in the page section. The news is a module what can be edit in the CMS. So the news must me linked to the home page but without having to to this body of page.
  • edited 3:43PM
    In your layout you can just specify the body area to be that top area above the news. Then you can just add that news area as part of the layout right below the <?=fuel_var('body','')?> but using php code like so:
    <?php $news = fuel_model('news', array('find' => 'all'); foreach($news as $item): ?> ...// html for news items goes here and you can reference the properties like $item->title, $item->content... etc <?php endforeach;?>
    Or you can create a block (either static or in the CMS) with similar code in it to render the news items and include it into the layout like so:
    <?=fuel_block('news')?>
    The block is good for if you may have a news area on another part of the site and you don't want it in the layout.
  • edited 3:43PM
    Great! I'm going to try that.

    Thanks.
Sign In or Register to comment.