Using the pages module for frontend views of my simple Modules

edited August 2015 in Modules
Hi,

I want to use the pages module also for loading my module frontend pages. Let's I have for example a module to display news. Now I want to have a page for the overview page and a page for the detail page.
I want to use the pages module, because I have some variables for the whole website, which should be configured via the page module.

Now I have a layout for this module pages which has 2 select fields. One for the module and one to select if it is the overview or the detail page.

Now I need some logic to get the data and prepare the correct view. In my opinion I must extend the page_router. Is this correct? Or do you have a better idea?

Comments

  • edited 9:26PM
    I just found the _module.php example layout for module pages...
    Got a new idea :-)
    I just have to make a layout for each of my simple modules. right?
  • edited 9:26PM
    Yes... that's the idea.
  • edited August 2015
    hmm anyway I have a question :-)
    I used the _module.php as copy template for a module layout. Just wanted to try the layout without doing any adjustments but by using the layout for a new page and then calling the page I get an error:

    Severity: Notice
    Message: Undefined variable: segment
    Filename: _layouts/fahrzeuge_module.php
    Line Number: 4

    Severity: Notice
    Message: Undefined variable: model
    Filename: _layouts/fahrzeuge_module.php
    Line Number: 37

    Where do I have to submit the values for this 2 variables? or are the variables just placeholders to be replaced in the actual layout file?
  • edited 9:26PM
    Have you read this part about generated post pages (in 1.3).
    http://docs.getfuelcms.com/modules/simple#post_pages

    If you want to use the _module.php layout, you'll need to create a class that extends the Fuel_module class and create a view that either loads the _module.php file copy and paste it into a new layout view file... however, the method in the generated post pages is probably preferred.
    $news_layout = new Fuel_module('news'); $news_layout->set_model('news_model'); $news_layout->set_view('_module'); $news_layout->set_label('News');
    http://docs.getfuelcms.com/general/layouts
  • edited 9:26PM
    Hey,
    I think I will use the layout object, because I have a kind of very custom page design.
    But here I have another question... The Fuel_layout class does not have a method to set the class name for the layout... In the array I have a parameter class... how do I initialize the layout object with the class name? Same for class filename
  • edited August 2015
    [deleted]
  • edited 9:26PM
    The first line that says new Fuel_module is the class... this extends the default Fuel_layout class.
  • edited 9:26PM
    Ah i am dumb... ;-)
    Thanks!!!
Sign In or Register to comment.