User guide advanced modules missing info ?

edited December 2010 in Modules
Hello,

I've been trying the past hours to make appear in the admin panel a list of modules and sub-modules like the blog one.
I've read the "advanced module" in the user guide
(http://www.getfuelcms.com/user_guide/modules/advanced)

But whatever I did was not enough to make appear my list of modules...

I then made a copy of the entire blog folder and made a search and replace of the word "blog".
I didn't forget to rename all files with the "blog" term inside...

Still no success...

When i finally found someting in a file not mentionned as far as i know (maybe i've been too tired to see it) in the advanced module in the user guide.

\fuel\application\config\MY_fuel.php

$config['modules_allowed'] = array(
	'user_guide',
	'blog',
	'backup',
	'seo',
	'validate',
	'tester',
	'cronjobs',
	'quiz'
	);
Then when i finally added my "quiz" module... Yippi my list of modules appear in the admin in the left menu.

So my question is :
Is it something you forgot to mention, or did i misunderstood something in the user guide ?

Lionel

Comments

  • edited 7:13PM
    Sorry about that... yes... I forgot to mention that. I'll add it to the user guide so others don't have the problem.
  • edited 7:13PM
    I'm glad i could help :) and thanks for you quick answer !

    Now i have another issue.

    When I create a simple module, I can edit my table data via the admin.
    I guess FUEL creates automatically forms to edit.

    But with advanced module, does fuel to that too ?
    /fuel/quiz/categories/edit/0
    Gives me a : 404 page not found.
  • edited 7:13PM
    FUEL creates the forms around the models. An "advanced" module, usually contains several models for you to edit (e.g. the blog is like this). If you look at the fuel/modules/blog/config folder, you'll see a blog_fuel_modules.php file. In that file, it provides the name of the module as the key to the $modules array. In the blog posts case, the key is 'blog_posts'. However, we wanted the fuel admin url to be blog/posts. To change that, we create a route in the blog_routes.php file. We also, have the module_uri property set to blog/posts in the blog_fuel_modules.php file.
  • edited 7:13PM
    Thanks :)

    I don't know how exactly but it works now... I can create, edit, delete categories in my module.
  • edited 7:13PM
    Hiya,
    Thanks for the cool CMS...
    I found another typo in the advanced module guide:
    $route[FUEL_ROUTE.'tools/user_guide/:any'] = 'user_guide/$1';
    should be:
    $route[FUEL_ROUTE.'tools/user_guide/(:any)'] = 'user_guide/$1';
    I think a tutorial on how to convert a simple module to an advanced module would be helpful.
    Thanks,
    Jordan
  • edited 7:13PM
    Instead of extending Fuel_base_controller.php, to inherit most of the simple module functionality I'm doing this in my advanced module controller:
    require_once(INSTALL_ROOT.'/modules/fuel/controllers/module.php'); class Films extends Module { function __construct() { parent::__construct(); } }

    Would you recommend this? Seems to be working so far...
  • edited 7:13PM
    Yep... that controller inherits from Fuel_base_controller so you should have all the base functionality there as well.

    I've updated the online user guide to help avoid that confusion as well as to fix the (:any) typo in the route.
  • edited November 2011
    Hi,
    Thanks!
    A note on my progress...I don't think $CI->load->module_model() is documented, I had to use that instead of $CI->load->model() from some of my other models. And I don't think advanced modules are supported in the foreign_keys variable in Base_module_model. So I had to make an empty simple model that extended my advanced model to get the foreign keys / option dropdown to work. Is there a better way?
    Thanks,
    Jordan
  • edited 7:13PM
    For your foreign key you can try something like this:
    public $foreign_keys = array('foreign_id' => array('my_module' => 'my_model'));
    Also, you should be able to use this syntax as well to load in a model from a different module:
    $CI->load->model('my_module/my_model');
  • edited 7:13PM
    That worked! Thanks!
  • edited 7:13PM
    Hi,
    I'm having a lot of trouble with custom fields and custom views in my advanced module. I have two questions:
    1) How do I create a custom field from the form_fields method? I want to show an image and have radio buttons to choose values associated with it. I tried:
    $fields['Test'] = array('type' => 'custom');
    but I don't know how to edit the custom field. In my advanced controller I tried overriding the edit() and _form() methods, adding $this->form_builder->create_custom('my_custom_field', $vars); to the _form() method, and adding this method:
    function my_custom_field($params) { return "test form data"; }
    but I get this error: call_user_func(my_custom_field)]: First argument is expected to be a valid callback.
    Also, what am I supposed to send my_custom_field for $params?

    2) I'm having trouble loading my own views into the advanced module. I placed a custom view in my module/views folder. I know about $this->load->module_view(); but I am trying to run _render from _edit to replace this function:
    $this->_render($this->views['create_edit'], $vars);
    I tried something like
    $this->_render($this->views['films/views/films_create_edit'], $vars, 'films_model'); but it can't find the file.
    Thanks,
    Jordan
  • edited December 2011
    For the custom field, you should be able to use the following:
    $form['my_custom_field'] = array('label' => ' My Label', 'type' => 'custom', 'func' => 'my_custom_field');
    If your function is a method on an object, you can use:
    array($my_obj, 'my_custom_field)
    Your function should accept a single array argument and in this case would be passed the $form['my_custom_field'] array.

    For the view, try setting a controller property of "view_path" equal to your modules name:
    ... public $view_location = 'my_module'; ....
  • edited December 2011
    The custom field code worked, thanks!
    $view_path didn't work, and neither did controller property $view_location (which I found in blog/settings), but simply $this->_render('films/films_create_edit', $vars); did.
    Thanks,
    Jordan
  • edited 7:13PM
    Ahh... yes it's view_location (I changed it above to avoid confusion). Does this work for you when you add the module in the third parameter:
    $this->_render('films/films_create_edit', $vars, 'films')
Sign In or Register to comment.