⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to access the session variables from the add.php in grocery crud?



Katherine

Katherine
  • profile picture
  • Member

Posted 10 August 2013 - 11:49 AM

I modified the add.php in grocery crud and add an iframe that shows the image crud. Now i need to add a conditional statement so that this iframe will show for some specific tables only. I set a flag in the controller for this. And my problem now is I dont know how will i access this session because

$this->session->userdata('isUploadVisible');

will generate an error

Severity: Notice

Message: Undefined property: Grocery_CRUD::$session

Filename: views/add.php

Line Number: 2

This add.php is the one that can be found in

      assets/grocery_crud/themes/datatables/views/add.php

davidoster

davidoster
  • profile picture
  • Member

Posted 11 August 2013 - 05:19 AM

Hello [member=katherine].

Yuor logic is a little bit restricting the way you do it because you will need to modify the render function somehow in order to pass this session variable on the add view.

If you want to follow this path you need to have something like this (just an example from this integration),

$state = $this->g_crud->getState();
		$state_info = $this->g_crud->getStateInfo();
		switch($state)
		{
			case 'add':
			case 'success':
			case 'update':
				$this->_gc_output($output);
				break;
			case 'edit':
				$primary_key = $state_info->primary_key;
				$this->_gc_output($output);
				break;
			case 'insert':
			case 'upload':
			case 'delete':
			case 'delete_file':
			case 'list':
			
			default:
				$output3 = (object)array('output' => $output->output . $output2->output, 'js_files' => array_merge($output->js_files,$output2->js_files), 'css_files' => array_merge($output->css_files,$output2->css_files));
				$this->_gc_output($output3);
				break;
		}

Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 12 August 2013 - 13:58 PM

Hello Katherine.

There can be 1 more possible way to access the data ..

you need to define the

$ci &= get_instance();

then u can use $ci->session->userdata .. and that should work.


jay_patel

jay_patel
  • profile picture
  • Member

Posted 01 January 2015 - 07:22 AM

Hello Katherine.

There can be 1 more possible way to access the data ..

you need to define the

$ci &= get_instance();

then u can use $ci->session->userdata .. and that should work.

 

i tried  this but $ci is null...