Jump to content


pbcomput

Member Since 18 Dec 2013
Offline Last Active Apr 07 2014 01:10 PM
-----

Posts I've Made

In Topic: [updated 24/11/2012] Dependent dropdown (library)

04 April 2014 - 10:27 AM

Hi,

 

I am using this library to make something like category and subcategory. But I am not getting proper value in select boxes of category and sub category. Below is my code, can anyone please check my code and tell me, where I am doing wrong.

 

In my example the themes are as category and subthemes are as subcategory.

// THEME & SUBTHEME
	function check_theme ()
	{
		$crud = new grocery_CRUD();
		$crud->set_table('articles');
		$crud->set_relation('article_theme_id', 'themes', 'theme_name');
		$crud->set_relation('article_subtheme_id', 'sub_themes', 'subtheme_name');
		$crud->unset_add_fields('article_content');

		$this->load->library('gc_dependent_select');
		// settings

		$fields = array(

		// first field:
		'Themes' => array( // first dropdown name
		'table_name' => 'themes', // table of country
		'title' => 'theme_name', // country title
		'relate' => null // the first dropdown hasn't a relation
		),
		// second field
		'SubThemes' => array( // second dropdown name
		'table_name' => 'sub_themes', // table of state
		'title' => 'subtheme_name', // state title
		'id_field' => 'subtheme_id', // table of state: primary key
		'relate' => 'theme_ids', // table of state:
		'data-placeholder' => 'select subthem' //dropdown's data-placeholder:

		),
		);

		$config = array(
		'main_table' => 'articles',
		'main_table_primary' => 'article_id',
		"url" => base_url().'index.php/'.__CLASS__.'/'.__FUNCTION__.'/', //path to method
		'ajax_loader' => base_url().'img/ajax-loaders/ajax-loader-2.gif', // path to ajax-loader image. It's an optional parameter
		'segment_name' =>'Your_segment_name' // It's an optional parameter. by default "get_items"
		);
		$categories = new gc_dependent_select($crud, $fields, $config);

		// first method:
		//$output = $categories->render();

		// the second method:
		$js = $categories->get_js();
		$output = $crud->render();
		$output->output.= $js;
		$this->_example_output($output);
	}

Here is the screenshots of my above code. By default its showing all records of themes and subthemes. But I want only those subtheme which theme selected from the theme dropdown.

 

wP9Preh.png

 

MWsVNU9.png

Thanks for your help.! :)


In Topic: callback_before_insert not working for created date

21 March 2014 - 03:57 PM

Hi Amit,

 

Thanks for your help.

 

I changed type to hidden but still it's not working. Note that, the data type of field is date so I got my mistake and changed date format to 

$post_array['nt_created_dt'] = date('Y-m-d');

I thought it will work now after corrected the date format, but still no use. 

 

can you please check again my code?

 

Thanks.


In Topic: Callback before delete file, delete thumbnail

31 December 2013 - 05:17 PM

Finally, I got the solution. which is as below. 

function delete_thumb($primary_key)
	{
		$user= $this->db->where('member_id',$primary_key)->get('member')->row();
  
		$url= 'assets/uploads/files/'.$user->profile_photo;
		$thumb_url= 'assets/uploads/files/thumb1-'.$user->profile_photo;
		unlink($url);
		unlink($thumb_url);

	   
	    return true;
	}

I hope it may help someone who is facing issue for deleting image.

 

Thanks


In Topic: fancybox in "read"

31 December 2013 - 06:49 AM

Hello,

 

I am having same issue / question. Does any one know how to achieve it? Please guide. It will be very helpful to me.

 

Thanks.


In Topic: Callback before delete file, delete thumbnail

24 December 2013 - 03:42 PM

Hi,

 

I am trying to remove thumbnail which I store in same folder. I code like below, but its not removing thumbnail when I delete the image. 

 

my code in function

$crud->callback_before_delete(array($this,'delete_thumb'));

callback function code

public function delete_thumb($primary_key)
	{
	    $row = $this->db->where('member_id',$primary_key)->get('member')->row();

	    unlink('/assets/uploads/files/thumb1-'.$row->profile_photo);
	   
	    return true;
	}

If anyone have solution for this, please help me to solve the issue.

 

Thanks. :)