Codeigniter shopping cart v1.1 Part 2 categories module


We start creating a module. The first one is the categories module.

When you create a category, you need to enter the category name, Short Description and Long Description.
We are using TinyMCE in short and long description area.

Download Page

Module: Categories

There is a status drop-down to select active and inactive.
If you want to create a sub-category, select a parent category from ‘Category Parent’ drop-down. There will be all the category you created.

I have added an accordion on the right side in Create Category page. You can modify it in categories/views/admin/category_right.php which you can find at the end of this page.

In the Category home page, I used dataTables so that you can sort, search, display different numbers of record etc.

Database

Dump the following sql.

CREATE TABLE IF NOT EXISTS `omc_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `shortdesc` varchar(255) NOT NULL,
  `longdesc` text NOT NULL,
  `status` enum('active','inactive') NOT NULL,
  `parentid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=96 ;

mytools plugin

We are going to make a plugin called mytools_pi.php in module\categories\plugins folder.

When you create a new category, this will create a new folder and thumbnails folder in it. When you delete it, this will delete the folder and sub-folders and files as well.

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * system/application/plugins/mytools_pi.php
 * This will replace all non English to _/under bar.
 *
 */
function createfoldername($string){
		$string = mb_strtolower($string,'utf-8');
		$regexp = '/( |g)/iU';
		// $regexp = '/( |å|ø|æ|Å|Ø|Æ|Ã¥|ø|æ|Ã…|Ø|Æ)/iU';
		$replace_char = '_';
		$data = preg_replace($regexp, $replace_char, $string);
		return $data;
 }

 /*
  * This will replace non English to similar letter in English
  *
  */
 function createdirname($string){

		$forbidden = array(" ", "å", "Å","ø", "Ø", "æ", "Æ", "ã…", "ã˜","ã†", "ã¥", "ã¸", "ã¦" );
		// order is space, å, Å,ø, Ø,æ, Æ, and Å, Ø, Æ, å,ø,æ
		$normal = array("_", "aa", "aa", "o", "o", "ae", "ae","aa","o", "ae", "aa", "o", "ae" );
		$string = str_replace($forbidden, $normal, $string);
		$data = mb_strtolower($string,'utf-8');
		return $data;
 }

 function create_path($folder)
    {
        // create dir if not exists
        $folder = explode( "/" , $folder );
        $mkfolder = "";
        //sets the complete directory path
        for(  $i=0 ; isset( $folder[$i] ) ; $i++ )
        {
            $mkfolder .= $folder[$i] . '/';
            if(!is_dir($mkfolder )) {
			  mkdir("$mkfolder");
			  mkdir("$mkfolder/thumbnails");
			}
        }
    }

	// ------------ lixlpixel recursive PHP functions -------------
 // recursive_remove_directory( directory to delete, empty )
 // expects path to directory and optional TRUE / FALSE to empty
 // of course PHP has to have the rights to delete the directory
 // you specify and all files and folders inside the directory
 // ------------------------------------------------------------

 // to use this function to totally remove a directory, write:
 // recursive_remove_directory('path/to/directory/to/delete');

 // to use this function to empty a directory, write:
 // recursive_remove_directory('path/to/full_directory',TRUE);

 function recursive_remove_directory($directory, $empty=FALSE)
 {
	 // if the path has a slash at the end we remove it here
	 if(substr($directory,-1) == '/')
	 {
		 $directory = substr($directory,0,-1);
	 }

	 // if the path is not valid or is not a directory ...
	 if(!file_exists($directory) || !is_dir($directory))
	 {
		 // ... we return false and exit the function
		 return FALSE;

	 // ... if the path is not readable
	 }elseif(!is_readable($directory))
	 {
		 // ... we return false and exit the function
		 return FALSE;

	 // ... else if the path is readable
	 }else{

		 // we open the directory
		 $handle = opendir($directory);

		 // and scan through the items inside
		 while (FALSE !== ($item = readdir($handle)))
		 {
			 // if the filepointer is not the current directory
			 // or the parent directory
			 if($item != '.' && $item != '..')
			 {
				 // we build the new path to delete
				 $path = $directory.'/'.$item;

				 // if the new path is a directory
				 if(is_dir($path))
				 {
					 // we call this function with the new path
					 // you need to change to $this->recursive_remove_directory($path);
					 // in controller.
					 recursive_remove_directory($path);

				 // if the new path is a file
				 }else{
					 // we remove the file
					 unlink($path);
				 }
			 }
		 }
		 // close the directory
		 closedir($handle);

		 // if the option to empty is not set to true
		 if($empty == FALSE)
		 {
			 // try to delete the now empty directory
			 if(!rmdir($directory))
			 {
				 // return false if not possible
				 return FALSE;
			 }
		 }
		 // return success
		 return TRUE;
	 }
 }
 /**
  * If you delete a category, you may be creating product orphans.
  * Find in omc_product table, select product id and name where product's
  * category_id is $id
  *
  * original code
  * $this->db->select('id,name');
  * $this->db->where('category_id',id_clean($id));
  * $Q = $this->db->get('omc_product');
  *
  * $id is the id number i.e. 6 or 12
  * $orphan_id is the name of id i.e products_id where you are looking for orphans
  * $db_table is the name of table omc_product etc
  *
  * If I use (in mcats, instead of checkOrphans($id) )
  * or in morders, $id will be order id
  * When I delete an order there might be order-item orphans
  * When I delete an product there might be order-item orphans
  * When I delete a customer there might be order orphans
  *
  */

  function findOrphans($id, $orphan_id, $db_table){
 	// delete a customer from omc_customer table
	// if $db_table is omc_customer, this will create customer_id
	// then find customer_id in omc_order table to find orphans
	/**
	 * delete an order from omc_order table. this will create order_items orphans in omc_order_item
	 * find order_item where order_id is
	 *
	 *
			  */
	$tablename = explode("-", $db_table);
	$tableid = $tablename[1]."_id";

	// or
	// $id_name = preg_replace('/.*_(.*)/', '${1}_id', $db_table);

	$data = array();
	// $this->db->select($tableid.',name');
 	$this->db->select($tableid,'name');
 	$this->db->where($orphan_id,id_clean($id));
 	$Q = $this->db->get($db_table);
    if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[$row['id']] = $row['name'];
       }
    }
    $Q->free_result();
    return $data;  	

 }

Categories Controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends Admin_Controller {
  	function Admin(){
	    parent::Admin_Controller();
	    // Check for access permission
		check('Categories');

		$this->load->model('MCats');

		// Set breadcrumb
		$this->bep_site->set_crumb($this->lang->line('backendpro_categories'),'categories/admin');	

		$this->load->plugin('mytools');

		mb_internal_encoding('UTF-8');

  	}

  	function index(){
		$data['title'] = "Manage Categories";
		$data['categories'] = $this->MCats->getAllCategories();
		$data['header'] = $this->lang->line('backendpro_access_control');
		$data['page'] = $this->config->item('backendpro_template_admin') . "admin_cat_home";
		$data['module'] = 'categories';
		$this->load->view($this->_container,$data);
  	}

  	function create(){
		$this->bep_assets->load_asset_group('TINYMCE');

	   	if ($this->input->post('name')){
	  		$this->MCats->addCategory();
			$string = $this->input->post('name');
			$folder = createdirname($string);
			$folder = 'assets/images/'.$folder;
			create_path($folder);

	  		// we used to use like this. $this->session->set_flashdata('message','Category created');
	  		// now we are using Bep's flashMsg function to show messages.
			flashMsg('success',$this->lang->line('userlib_category_created'));
			redirect('categories/admin/index','refresh');
	  	}else{
			$data['title'] = "Create Category";
			$data['categories'] = $this->MCats->getTopCategories();
			$data['right'] = 'admin/category_right';

			// Set breadcrumb
			$this->bep_site->set_crumb($this->lang->line('userlib_category_create'),'categories/admin/create');	

			$data['header'] = $this->lang->line('backendpro_access_control');
			$data['page'] = $this->config->item('backendpro_template_admin') . "admin_cat_create";
			$data['module'] = 'categories';
			$this->load->view($this->_container,$data);
		}
  	}

  	function edit($id=0){
	  	$this->bep_assets->load_asset_group('TINYMCE');

	  	if ($this->input->post('name')){
	  		$this->MCats->updateCategory();

	  		flashMsg('success',$this->lang->line('userlib_category_updated'));
	  		redirect('categories/admin/index','refresh');
	  	}else{
			//$id = $this->uri->segment(4);
			$data['title'] = "Edit Category";
			// $data['main'] = 'admin_cat_edit';
			$data['page'] = $this->config->item('backendpro_template_admin') . "admin_cat_edit";
			$data['category'] = $this->MCats->getCategory($id);
			$data['categories'] = $this->MCats->getTopCategories();
			$data['right'] = 'admin/category_right';
			if (!count($data['category'])){
				redirect('admin/categories/index','refresh');
			}

			// Set breadcrumb
			$this->bep_site->set_crumb($this->lang->line('userlib_category_edit'),'categories/admin/edit');	

			$data['header'] = $this->lang->line('backendpro_access_control');
			$data['module'] = 'categories';
			$this->load->view($this->_container,$data);
		}
  	}

  	function delete($id){

		$cat = $this->MCats->getCategory($id);
		$string = $cat['name'];
		$catname = createdirname($string);
		$catname = 'assets/images/'.$catname;
		recursive_remove_directory($catname, $empty=FALSE);	

		$orphans = $this->MCats->checkOrphans($id);
		if (count($orphans)){
			$this->session->set_userdata('orphans',$orphans);
			redirect('categories/admin/reassign/'.$id,'refresh');
		}else{
		    $this->MCats->deleteCategory($id);

			flashMsg('success',$this->lang->line('userlib_category_deleted'));
		    redirect('categories/admin/index','refresh');
		}
  	}

  	function export(){
	  	$this->load->helper('download');
	  	$csv = $this->MCats->exportCsv();
	  	$name = "category_export.csv";
	  	force_download($name,$csv);
	 }

  	function reassign($id=0){
		if ($_POST){
			$this->load->module_model('products','MProducts');
			$this->MProducts->reassignProducts();
			$id = $this->input->post('id');
			$this->MCats->deleteCategory($id); // this is not working at the moment. 

			flashMsg('success',$this->lang->line('userlib_category_reassigned'));
			redirect('categories/admin/index','refresh');
		}else{
			//$id = $this->uri->segment(4);
			$data['category'] = $this->MCats->getCategory($id);
			$data['title'] = "Reassign Products";
			$data['main'] = 'admin_cat_reassign';
			$data['categories'] = $this->MCats->getCategoriesDropDown();
			// Set breadcrumb
			$this->bep_site->set_crumb($this->lang->line('userlib_category_reassign'),'categories/admin/reassign');	

			$this->load->vars($data);
			$this->load->view('dashboard');
		}
	}

	function changeCatStatus($id){
		//$id = $this->uri->segment(4);
		$this->MCats->changeCatStatus($id);

		flashMsg('success',$this->lang->line('userlib_category_status'));
		redirect('categories/admin/index','refresh');
  	}

  	function _remove_path($folder){

	    $files = glob( $folder . DIRECTORY_SEPARATOR . '*');
	    foreach( $files as $file ){
	        if($file == '.' || $file == '..'){continue;}
	        if(is_dir($file)){
	            $this->_remove_path( $file );
	        }else{
	            unlink( $file );
	        }
	    }
	    rmdir( $folder );
  	}

}//end class
?>

Please note that we are calling a MProducts model which we haven’t added yet. And also change in the following lines. We are loading mytools plugin and using its function here.

...
// Loading plugin mytools which we have added earlier
		$this->load->plugin('mytools');
...
...
// we used to use like this. $this->session->set_flashdata('message','Category created');
// now we are using Bep's flashMsg function to show messages.
flashMsg('success',$this->lang->line('userlib_category_created'));

...
...

// createdirname function is from plugin mytools.php
			$folder = createdirname($string);
...
...
// This is how BackendPro do
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_cat_create";
$data['module'] = 'categories';
$this->load->view($this->_container,$data);

Now you need to add the followings to C:\xampp\htdocs\ci_bep2\modules\auth\language\english\userlib_lang.php

/* Categories module */
$lang['userlib_category_created'] = 'Category created';
$lang['userlib_category_updated'] = 'Category updated';
$lang['userlib_category_deleted'] = 'Category deleted';
$lang['userlib_category_reassigned'] = 'Category deleted and products reassigned';
$lang['userlib_category_status'] = 'Category status changed';

Module Categories Model MCats

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * This is for ci_bep
 *
 */
class MCats extends Model{

	function MCats(){
		parent::Model();
	}

function getCategory($id){
    $data = array();
    $options = array('id' =>id_clean($id));
    $Q = $this->db->getwhere('omc_category',$options,1);
    if ($Q->num_rows() > 0){
      $data = $Q->row_array();
    }

    $Q->free_result();
    return $data;
 }

 function getAllCategories(){
     $data = array();
     $Q = $this->db->get('omc_category');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
       }
    }
    $Q->free_result();
    return $data;
 }

 function getSubCategories($catid){
// this runs when $cat['parentid'] < 1 in controllers/welcom.php
// Which means 0 and they are main/top categories.
//e.g. 7 and 8 have parent id 0
     $data = array();
     $this->db->select('id,name,shortdesc');
     $this->db->where('parentid', id_clean($catid));
     // When $catid is 7, which has 0 for parent id, and looking for items where parentid is this 7 $catid
     $this->db->where('status', 'active');
     $this->db->orderby('name','asc');
     $Q = $this->db->get('omc_category'); // this will gives series of items such as 1 shoes, 2 shirts, 3 pants etc.
     if ($Q->num_rows() > 0){// if there are items then
       foreach ($Q->result_array() as $row){//each item as an array to $row
       		$sql = "select thumbnail as src
       				from products
       				where category_id=".id_clean($row['id'])."
       				and status='active'
       				order by rand() limit 1";

       		$Q2 = $this->db->query($sql);
		// then run a quary. select one thumbnail randumly from products where category_id is $row['id']
		// e.g shirts has 2 for $row['id']

			if($Q2->num_rows() > 0){
					$thumb = $Q2->row_array();
				$THUMB = $thumb['src']; // the result src which is result thumbnail is $THUMB
			}else{
				$THUMB = '';// otherwise none in $THUMB
			}

       		$Q2->free_result();
			$data[] = array(
				'id' => $row['id'],
				'name' => $row['name'],
				'shortdesc' => $row['shortdesc'],
				'thumbnail' => $THUMB
			);
       	}
    }
    $Q->free_result();  

    return $data; 

 }

 function getCategoriesNav(){
     $data = array();
     $this->db->select('id,name,parentid');
     $this->db->where('status', 'active');
     $this->db->orderby('parentid','asc');
     $this->db->orderby('name','asc');
     $this->db->groupby('parentid,id');
     $Q = $this->db->get('omc_category');
     if ($Q->num_rows() > 0){
       foreach ($Q->result() as $row){
	// see the output $navlist at http://127.0.0.1/codeigniter_shopping/test1/cat/7
			if ($row->parentid > 0){
				$data[0][$row->parentid]['children'][$row->id] = $row->name;
				// [0]=>array([7]=>array([children]=>array([4]=dresses)))
				// [0][8][children][5]=toys
			}else{
				$data[0][$row->id]['name'] = $row->name;
				// e.g. [0]=>array([7]=>array([name]=clothes))
				// e.g. [0][8][name]=fun
			}
		}
    }
    $Q->free_result();
    return $data;
 }

 function getCatNav($parentid){
     $data = array();
     $this->db->where('status', 'active');
	 $this->db->where('parentid', $parentid);
     $this->db->orderby('name','asc');
     $Q = $this->db->get('omc_category');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
				$data[$row['id']] = $row['name'];
			}
		}
    $Q->free_result();
    return $data;
 }

 function getCategoriesDropDown(){
     $data = array();
     $this->db->select('id,name');
     $this->db->where('parentid !=',0);
     $Q = $this->db->get('omc_category');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[$row['id']] = $row['name'];
       }
    }
    $Q->free_result();
    return $data;
 }

 function getTopCategories(){
     $data[0] = 'root';
     $this->db->where('parentid',0);
     $Q = $this->db->get('omc_category');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[$row['id']] = $row['name'];
       }
    }
    $Q->free_result();
    return $data;
 }	

 function addCategory(){
	$data = array(
		'name' => db_clean($_POST['name']),
		'shortdesc' =>  db_clean($_POST['shortdesc']),
		'longdesc' =>  db_clean($_POST['longdesc'],5000),
		'status' =>  db_clean($_POST['status'],8),
		'parentid' => id_clean($_POST['parentid'])

	);

	$this->db->insert('omc_category', $data);
 }
  function addsubMenu($id){
	$data = array(
		'name' => db_clean($_POST['name']),
		'shortdesc' =>  db_clean($_POST['shortdesc']),
		'longdesc' =>  db_clean($_POST['longdesc'],5000),
		'status' =>  db_clean($_POST['status'],8),
		'parentid' => id_clean($_POST['parentid'])

	);

	$this->db->insert('omc_category', $data);
 }

 function updateCategory(){
	$data = array(
		//'name' =>  db_clean($_POST['name']),
		'shortdesc' =>  db_clean($_POST['shortdesc']),
		'longdesc' =>  db_clean($_POST['longdesc'],5000),
		'status' =>  db_clean($_POST['status'],8),
		'parentid' =>  id_clean($_POST['parentid'])

	);

 	$this->db->where('id', id_clean($_POST['id']));
	$this->db->update('omc_category', $data);	

 }

 function deleteCategory($id){
 	// $data = array('status' => 'inactive');
 	$this->db->where('id', id_clean($id));
	$this->db->delete('omc_category');
 }

 function exportCsv(){
 	$this->load->dbutil();
 	$Q = $this->db->query("select * from omc_category");
 	return $this->dbutil->csv_from_result($Q,",","\n");
 }

 function checkOrphans($id){
 	$data = array();
 	$this->db->select('id,name');
 	$this->db->where('category_id',id_clean($id));
 	$Q = $this->db->get('omc_product');
    if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[$row['id']] = $row['name'];
       }
    }
    $Q->free_result();
    return $data;  	

 }

 function changeCatStatus($id){
	// getting status of page
	$catinfo = array();
	$catinfo = $this->getCategory($id);
	$status = $catinfo['status'];
	if($status =='active'){

		$data = array('status' => 'inactive');
		$this->db->where('id', id_clean($id));
		$this->db->update('omc_category', $data);	

	}else{

		$data = array('status' => 'active');
		$this->db->where('id', id_clean($id));
		$this->db->update('omc_category', $data);
	}

 }

 function getCategoryNamebyProduct($category_id){
  $this->db->select("id,name");
  $this->db->where('id', $category_id);
  $this->db->where('status', 'active');
  $sql = $this->db->get('omc_category');

if ($sql->num_rows() > 0){
       foreach ($sql->result_array() as $row){
         $data[$row['id']] = $row['name'];
       }
    }
    $sql->free_result();
    return $data;
 }

}

?>

Views

We need to create admin_cat_create.php, admin_cat_edit.php, admin_cat_home.php, admin_cat_reassign.php and category_right.php in modules/categories/views/admin/ folder.

admin_cat_create.php

<div id="pageleftcont">
<h2><?php echo $title;?></h2>
<div id="create_edit">
<?php
echo form_open('categories/admin/create');
echo "\n<p><label for='catname'>Name</label><br/>\n";
$data = array('name'=>'name','id'=>'catname','size'=>25);
echo form_input($data) ."</p>\n";

echo "<p><label for='short'>Short Description</label><br/>\n";
$data = array('name'=>'shortdesc','id'=>'short','rows'=>5, 'cols'=>'40');
echo form_textarea($data) ."</p>\n";

echo "<p><label for='long'>Long Description</label><br/>\n";
$data = array('name'=>'longdesc','id'=>'long','rows'=>5, 'cols'=>'40');
echo form_textarea($data) ."</p>\n";

echo "<p><label for='status'>Status</label><br/>\n";
$options = array('active' => 'active', 'inactive' => 'inactive');
echo form_dropdown('status',$options) ."</p>\n";

echo "<p><label for='parent'>Category Parent</label><br/>\n";
echo form_dropdown('parentid',$categories) ."</p>\n";

echo form_submit('submit','create category');
echo form_close();

?>
</div>
</div>
<div id="pagerightcont">
  <?php $this->load->view($right);?>
    </div>

admin_cat_edit.php


<div id="pageleftcont">
<h2><?php echo $title;?></h2>
<div id="create_edit">
<?php
echo form_open('categories/admin/edit');

echo form_hidden('name', $category['name']);
/*
echo "<p><label for='update'>Update</label><br/>";
echo form_checkbox('update', 'update', TRUE);
*/
echo "<p><label for='catname'>Name</label><br/>";
echo "<h2>".$category['name']."</h2>";

echo "<p><label for='short'>Short Description</label><br/>";
$data = array('name'=>'shortdesc','id'=>'short','size'=>40, 'value' => $category['shortdesc']);
echo form_textarea($data) ."</p>";

echo "<p><label for='long'>Long Description</label><br/>";
$data = array('name'=>'longdesc','id'=>'long','rows'=>5, 'cols'=>'40', 'value' => $category['longdesc']);
echo form_textarea($data) ."</p>";

echo "<p><label for='status'>Status</label><br/>";
$options = array('active' => 'active', 'inactive' => 'inactive');
echo form_dropdown('status',$options, $category['status']) ."</p>";

echo "<p><label for='parent'>Category Parent</label><br/>";
echo form_dropdown('parentid',$categories,$category['parentid']) ."</p>";

echo form_hidden('id',$category['id']);
echo form_submit('submit','update category');
echo form_close();

?>
</div>
 </div>
    <div id="pagerightcont">
  <?php  $this->load->view($right);?>
    </div>

admin_cat_home.php

<?php print displayStatus();?>
<h2><?php echo $title;?></h2>
<p><?php echo anchor("categories/admin/create", "Create new category");?> | <?php echo anchor("categories/admin/export","Export");?></p>

<?php
if ($this->session->flashdata('message')){
	echo "<div class='status_box'>".$this->session->flashdata('message')."</div>";
}

if (count($categories)){
	echo "<table id='tablesorter' class='tablesorter' border='1' cellspacing='0' cellpadding='3' width='100%'>\n";
	echo "<thead>\n<tr valign='top'>\n";
	echo "<th>ID</th>\n<th>Name</th><th>Status</th><th>Parent id</th><th>Actions</th>\n";
	echo "</tr>\n</thead>\n<tbody>\n";
	foreach ($categories as $key => $list){
		echo "<tr valign='top'>\n";
		echo "<td>".$list['id']."</td>\n";
		echo "<td>".$list['name']."</td>\n";

		echo "<td align='center'>";
		echo anchor('categories/admin/changeCatStatus/'.$list['id'],$list['status'], array('class' => $list['status']));
		echo "</td>\n";

		// echo "<td align='center'>".$list['status']."</td>\n";

		echo "<td align='center'>".$list['parentid']."</td>\n";
		echo "<td align='center'>";
		echo anchor('categories/admin/edit/'.$list['id'],'edit');
		echo " | ";
		echo anchor('categories/admin/delete/'.$list['id'],'delete', array('class' => 'delete_link'));
		echo "</td>\n";
		echo "</tr>\n";
	}
	echo "</tbody>\n</table>";
}
?>

<h2><?php echo $title;?></h2>
<p>The following products are about to be orphaned. They used to belong to the <b><?php echo $category['name'];?></b> category, but now they need to be reassigned.</p>

<ul>
<?php
foreach ($this->session->userdata('orphans') as $id => $name){
	echo "<li>$name</li>\n";
}
echo "<pre>";
print_r ($category);
print_r ($categories);
echo "</pre>";
echo "</br >";
echo $categories[$category['id']];
echo $category['id'];
?>
</ul>

<?php
echo form_open('categories/admin/reassign');
unset($categories[$category['id']]);
echo form_dropdown('categories',$categories);
echo form_hidden('id', $category['id'] );
echo form_submit('submit','reassign');
echo form_close();
?>

category_right.php

<h2>Product Categories Notes</h2>
    <p>in module</p>
<div class="basic" id="accordion">
    <a>Categories</a>
    <div>
        <h3>Gallery</h3>
	<p>Add your notes here. This will be in jquery UI accordion.This is just an example.
	... Don't change the following categories under <b>Gallery</b> </p>

            <h4>Gallery 1</h4>
            <h4>Gallery 2</h4>
            <h4>Front top</h4>
            <h4>Front bottom</h4>
            <h4>Gallery Web design</h4>
    </div>

	<a>More info</a>
    <div>
	<h3>Some info</h3>
            <p>info info </p>
            <h3>Gallery 12</h3>
           <p>Go to Products and add images for web page Gallery 2</p>
           <h3>Front top</h3>
           <p>Go to Products and add images for web page Front top</p>
           <h3>Front bottom</h3>
           <p>Go to Products and add images for web page Front bottom</p>
           <h3>Gallery Webdesign</h3>
           <p>Go to Products and add images for web page Gallery Web design</p>
    </div>

    <a>Products</a>
    <div>
	<h3>Gallery 1</h3>
            <p>Go to Products and add images for web page Gallery 1</p>
            <h3>Gallery 2</h3>
           <p>Go to Products and add images for web page Gallery 2</p>
           <h3>Front top</h3>
           <p>Go to Products and add images for web page Front top</p>
           <h3>Front bottom</h3>
           <p>Go to Products and add images for web page Front bottom</p>
           <h3>Gallery Webdesign</h3>
           <p>Go to Products and add images for web page Gallery Web design</p>
    </div>

</div> <!--End of id accordion -->

CSS

Additional styling for menu pages. assets/css/admin.css

/* Style for pages with accordion */

#pagerightcont{
   width: 30%;
   float: left;

}

#pageleftcont {
   width: 68%;
   padding-right: 2%;
   float: left;

}
 #tablesorter td{
 	padding: 4px !important;
 }

 #pageleftcont h1, #pageleftcont h2, #pageleftcont h3, #pageleftcont h4, #pageleftcont h5 ,#pageleftcont h6{
 	border: none;

 }
form select {
	border: 1px solid #aaaaaa;
}

To be continued

We are ready for the next module.

2 comments to Codeigniter shopping cart v1.1 Part 2 categories module

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>