Need help with making Custom Module Front-end Views (Advanced Module)

I'm kind of recreating the simple modules into an advanced module. I'm now about to make the data available in the front-end.

If I simply create a /views/categories.php file in my module's directory (/mymodule for example), I don't see it when I open URI /mymodule/categories, so I made a controller named /controllers/categories.php, and set the $view_location as 'mymodule' and now I see the contents of /views/categories.php now, but it is wrapped in the admin UI. Any clues on how to make this display with the layout and theme of the front end UI?

Or am I doing it totally wrong and there is an easy way? Like maybe a configuration I may have missed that will trigger the views on my module to show up automatically in the front-end via their front-end URLs (/mymodule/categories) without creating controllers (I assumed there's such a way because of the opt-in controllers development).

Looking forward for some help. Thanks!

Comments

  • edited 12:30AM
    How are you loading the view for your page in your controller?
  • edited 12:30AM
    I created a Categories controller with the function index in it, function index has this line alone: $this->_render('categories');
  • edited 12:30AM
    Sorry for the delay... I missed your response on the Forum some how. The _render function is specific to rendering the Admin UI. Also, the opt-in controller method (where you don't need a controller) only works in the application folder and in modules, you'll need to use a controller.
  • edited 12:30AM
    Oh ok, no worries, thanks. So how do I make sure my output renders with the front-end template?
  • edited 12:30AM
    This page should help in the user guide where it talks about Using Controller:
    http://www.getfuelcms.com/user_guide/general/creating-pages
    class About extends Controller { function About() { parent::Controller(); } function contact() { // set your variables $vars = array('page_title' => 'Contact : My Website'); //... form code goes here // load the fuel_page library class and pass it the view file you want to load $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'about/contact')); $this->fuel_page->add_variables($vars); $this->fuel_page->render(); }
  • edited 12:30AM
    I got the front-end template loading. Minor issue is that it does not load from my module's views directory, it's loading from application/views.
  • edited 12:30AM
    Did this get resolved? I have the same question.

    Thanks.
  • edited 12:30AM
    You can specify the $view_location property for your controller (above the contsructor), and set it to the name of the advanced module you want to pull your view files from.
  • edited 12:30AM
    Thank you, I just wasn't sure if this was the intended solution or one users workaround.
Sign In or Register to comment.