Sorting filters

edited July 2014 in Modules
I created a category_id column on page table and refer that to the fuel_categories table. With

$config['module_overwrites']['pages'] = array(
'model_name' => 'sk_pages_model',
'table_headers' => array(
'id',
'location',
'layout',
'last_modified',
'categories',
'published',
),
'filters' => array('category_id' => array('label'=>'Category', 'type' => 'select', 'model' => 'fuel_categories', 'order'=>'precedence ASC')),
);

it successfully list all the category in the drop down box, however, i want to

1, list all the categories in the filter drop down according to precedence, the above code is not working
2, i want the default list of pages by the first options of the categories when the page is first time loaded.


how can i do these options?

Comments

  • edited 8:22AM
    There is a "model_params" option you can pass it to set the parameters for the method that is used to create that list (options_list). Code example:
    'model_params' => array('id', 'name', array(), 'precedence asc'), ....

    For #2, you may need to modify your model's list_items method to do something like the following:
    public function list_items($limit = NULL, $offset = NULL, $col = 'nav_key', $order = 'desc', $just_count = FALSE) { $CI =& get_instance(); if (!empty($this->filters)) { $this->filters['category_id'] = 1; } $data = parent::list_items($limit, $offset, $col, $order, $just_count); return $data; }
Sign In or Register to comment.