Chapter 7: Improving the Dashboard
191
To make the category dropdown work, you will need to update the index() function of the admin/
products controller. All you have to do is add one line, passing in a list of subcategory IDs and names.
In fact, all you have to do is copy a similar line from the edit() function:
function index(){
$data[‘title’] = “Manage Products”;
$data[‘main’] = ‘admin_product_home’;
$data[‘products’] = $this- > MProducts- > getAllProducts();
$data[‘categories’] = $this- > MCats- > getCategoriesDropDown();
$this- > load- > vars($data);
$this- > load- > view(‘dashboard’);
}
The result should look a lot like Figure 7 - 1.
Figure 7 - 1
Now it ’ s time to work on the batchmode() function. As you ’ re dealing with several important pieces of
data when you receive the form post, it might be a good idea to simply echo out what you receive. After
you parse out the data array, you can write a better function.