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
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
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
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
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.
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')),
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?
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.
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()