The route problem

edited January 2012 in Modules
Hello everyone.
I'm new to fuel cms, and I really like it, but came to a problem, and hoping for solution.
What I'm trying to do is, example: i have categories table, and I want to show in the list_items only categories that, for ex, have children elements. I thought to myself, ok, no problem I'll just change route settings, to be able to receive new uri segment, and then... problem...
Question: How can i pass uri segment to categories model in simple module, and than based on that variable search for that specific category, or this is impossible in simple modules ?
Thanks in advance.
I was trying to find this answer for over 3 days in this forum!

Comments

  • edited 1:20AM
    This is the list_items table in the Fuel admin?

    If so you'd probably be better off rewriting the sql in your version of the list_items method in your model.

    See "Changing the list view columns" here: http://getfuelcms.com/user_guide/modules/tutorial
  • edited 1:20AM
    Ok, I can do that in the list_items method, I can do
    if (hasChildren) or something like that,
    maybe this with children is not a good example... Let's say I want to be able to search all categories that have subcategory with id=5? How can I pass that id to the list_items method, from within same categories_model
  • edited 1:20AM
    Please if someone can help I'm desperate!
    Perhaps even more detailed:
    new ex.: when I click item on the list, I want to catch that items id, and then, for ex. open subcategories module and list only subcategories with selected id as subcategory parent_id
  • edited 1:20AM
    Ah, not on initial display, after a click in list_items..

    So you want to go list_items -> list_items -> form_fields?

    I'm not sure you can do that without using an advanced module. We'll need Dave's expertise!

    Given your example though, in the list items method for subcategories, you could also show the category parent and use that value to filter/search the list items table.
  • edited 1:20AM
    Are you wanting a drop down filter similar to the navigation module in which you can filter on navigation groups?

    If so you can add a filter parameter to you simple module configuration like so (this is the example from the fuel/modules/fuel/config/fuel_modules.php):
    'filters' => array('group_id' => array('default' => 1, 'label' => lang('form_label_navigation_group'), 'type' => 'select')),
  • edited 1:20AM
    I was thinking more like Lance said list_items -> list_items -> form_fields
    But this option with filters seems to be acceptable too, but I'm heaving trouble to figure it out how it works. I was trying to replicate navigation module and create my own simple module, but I've got lost... to many things for me
    Now I'm trying create news module with basic implementation of filter functionality, and what I've managed so far was to display filter combo box in top right with data populated from same table, in a way that was created in navigation controller :

    <?php
    require_once('module.php');

    class news extends Module {

    function __construct()
    {
    parent::__construct();
    }

    function items()
    {
    $CI =& get_instance();
    $CI->load->module_model(FUEL_FOLDER,'news_model');
    if (!empty($this->filters['headline'])) $this->filters['headline']['options'] = $this->news_model->options_list('id', 'headline', array(), false);
    parent::items();
    }
    }

    and MY_fuel_modules.php config look like this:

    $config['modules']['news'] = array(
    'preview_path' => 'news/{slug}',
    'filters' => array('headline' => array('default' => 'news', 'label' => 'search', 'type' => 'select'))
    );


    but when I change combo box nothing happens

    news_model is from your news tutorial

    Em I on the right track?
    What I'm doing wrong?
  • edited 1:20AM
    There is javascript used to controller that in the fuel/modules/fuel/assets/js/controller/NavigationController.js:
    items : function(){ // call parent fuel.controller.BaseFuelController.prototype.items.call(this); var _this = this; $('#group_id').change(function(e){ $('#form_table').submit(); }); },
    You can add your own js file with the module's js paramter.
  • edited 1:20AM
    Thanks, will try it and get back
  • edited 1:20AM
    Ok I've managed to refresh list using this js like u suggested, but it's not filtering, it's always empty table, and I can see it's refreshing, and it should be populated with selected headline?
  • edited 1:20AM
    You may need to look at the AJAX requests via Firebug or the developer console to see what's getting posted and if there are any errors.

    It should be posting to fuel/modules/fuel/controllers/modules.php file "items" method. You may also want to add some debug query statements in your model's list_items method like so to see what get's returned:
    $this->debug_query()
Sign In or Register to comment.