It looks like you're new here. If you want to get involved, click one of these buttons!
Controller is as so:
function list_items($limit = null, $offset = null, $col = 'id', $order = 'desc')
{
$this->db->where('archived', 'no');
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
as myste.com/admin/orders is shown I what to show myste.com/admin/orders/archives show the rows with archived=yes option.
require_once(FUEL_PATH.'controllers/module.php');
class Orders extends Module {
function __construct()
{
parent::__construct();
$this->load->module_model('invoice', 'orders_model');
}
public function _remap($method, $params = array())
{
if (method_exists($this, $method))
{
return call_user_func_array(array($this, $method), $params);
}
show_404();
}
function index(){
$this->items();
}
function items(){
parent::items();
}
function archives(){
// don't know how to show lists with archived=no
}
}
Comments
$this->model->is_admin = TRUE;
I have edited my post and removed the code so that you won't confuse.
I am wanting to filter data of list_items on different methods as specified above.
I think I have to explain on detail:
I have orders which have field archived with datatype enum('yes','no')
by default on fuel cms on list_items it shows all data with option yes and no.
for data with (archived=no) I want to show on this url: and for data with (archived=yes) I want to show on this url: I have added a controller named controllers/orders and on its index method I have displayed the data with parent::items of parent controller fuel/module.php
depending on the two mothods on controller/orders.php
on index method I want to show data with archived=no
on archives method I want to show data with archived=yes
I think I am clear.
function items(){ $this->model->db()->where(array('archived' => 'no')); $this->items(); } .... function archives(){ $this->model->db()->where(array('archived' => 'yes')); $this->items(); }
Or you could add a property to the model that you could toggle on and off in each method like so:
function list_items($limit = null, $offset = null, $col = 'id', $order = 'desc') { if (!$this->show_archived){ { $this->db->where('archived', 'no'); } else { $this->db->where('archived', 'yes'); } $data = parent::list_items($limit, $offset, $col, $order); return $data; }
Then in the controller:
function items(){ $this->model->show_archived = FALSE; $this->items(); } .... function archives(){ $this->model->show_archived = TRUE; $this->items(); }
Can you please check it from here
http://dl.dropbox.com/u/15106116/modules_invoice.rar
there are two modules:
-> group_access
-> invoice // this is mine module where the error persists
$this->debug_query();
Also, the method "archive" is actually part of the base_module_model and you are overwriting it which may cause some errors elsewhere. I'd recommend giving it a different name.
On first query it does correctly and switched between yes and no of archived
on other two query it always shows archived=no
This screenshot shall explain:
I would think that setting the model property would follow through to the "list_items_total" method call but maybe not in this case... Can you confirm?