Jump to content


MarkusD's Content

There have been 15 items by MarkusD (Search limited from 20-January 20)


By content type

See this member's

Sort by                Order  

#4763 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 16 December 2012 - 10:01 PM in Extra coding / Plugins

IT WORKS!!

THANK YOU A MILLION TIMES
GOD BLESS YOU

YOU ARE A LEGEND!

Thank you for your great intelligence and thank you for helping us so much!!



#4761 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 16 December 2012 - 09:54 PM in Extra coding / Plugins

and show your code please


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

class Atributos_Copia extends CI_Controller {

function __construct()
{
parent::__construct();

$this->load->library('grocery_crud');
$this->load->library('image_moo');
$this->load->library('gc_dependent_select');
}

public function index()
{
;


}




public function atributos_codigo()
{
$crud = new grocery_CRUD();
$crud->set_subject('Atributos');
$crud->set_table('atributos');
$crud->where('Email', $this->session->userdata('username'));

$crud->set_relation('id_objeto','object','object_name');
$crud->set_relation('id_seller','seller','seller_type');
$crud->set_relation('id_situation_s','situation','type_situation');
$crud->set_relation('id_transaction','transaction','transaction_type');

$crud->set_relation('id_pais', 'paises', 'nombre_pais');
$crud->set_relation('id_region', 'regiones', 'nombre_region');
$crud->set_relation('id_town', 'localidades', 'nombre_localidad');




$fields = array(

// first field:
'id_pais' => array( // first dropdown name
	 'table_name' => 'paises', // table of country
	 'title' => 'nombre_pais', // country title
	 'relate' => null // the first dropdown hasn't a relation
),

// second field
'id_region' => array( // second dropdown name
	 'table_name' => 'regiones', // table of state
	 'title' => 'nombre_region', // state title
	 'id_field' => 'id_region', // table of state: primary key
	 'relate' => 'id_pais', // table of state: id_pais es la foreign key de paises
	 'data-placeholder' => 'select state' //dropdown's data-placeholder:

),


// third field. same settings
'id_town' => array( // third dropdown name
	 'table_name' => 'localidades',
	 'order_by'=>"nombre_localidad DESC", // string. It's an optional parameter.
	 'title' => 'nombre_localidad', // now you can use this format )))
	 'id_field' => 'id_localidad',
	 'relate' => 'id_region',
	 'data-placeholder' => 'select city'
)
);



$config = array(
'main_table' => 'atributos',
'main_table_primary' => 'id_atributo',
"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/'

);

$categories = new gc_dependent_select($crud, $fields, $config);
// the second method:
$js = $categories->get_js();



#+++++++++++++++ UPLOADING AND RESIZING PICS+++++++++++++++++
$crud->set_field_upload('thumb_a','assets/uploads/thumbs'); # $crud->set_field_upload('pic1','assets/uploads/pics'); # a

$crud->callback_after_upload(array($this,'resize')); # 




	
$output = $crud->render();
$output->output.= $js;
$this->_example_output($output);

}


#+++++++++++++++++++RESIZING PICS ++++++++++++++++++++++++++++++++++++++++++

function resize($uploader_response,$field_info, $files_to_upload)
{

$thumb_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;

$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;

$this->image_moo->load($thumb_uploaded)->resize(160,120)->save($thumb_uploaded,true);

$this->image_moo->load($file_uploaded)->resize(600,400)->save($file_uploaded,true);



if($this->image_moo->error) {

print $this->image_moo->display_errors();
}

return true;

}

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


function _example_output($output = null)

{
$this->load->view('our_template.php',$output);
}

}



#4760 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 16 December 2012 - 09:52 PM in Extra coding / Plugins

show url to the controller and function


http://localhost/realestate/index.php/atributos_Copia/atributos_codigo



#4757 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 16 December 2012 - 09:27 PM in Extra coding / Plugins

Hello

When I start an Add

I get the first dropdown for country Active, so that I can select it, and the other two deactivated. Ok, so I select France and for the regions that come now I get this

"NetworkError: 404 Not Found - http://localhost/realestate/Atributos_Copia/atributos_codigo/get_items/id_region/64"

where 64 is the number that corresponds to France.

where is my error Viktor because I have really the same scheme than in your example, Countries, Regions and Cities

thank you a lot



#4756 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 16 December 2012 - 08:44 PM in Extra coding / Plugins

-



#4723 Trying to implement the library for interdependent select lists

Posted by MarkusD on 14 December 2012 - 09:29 AM in I have a question

.



#4722 Trying to implement the library for interdependent select lists

Posted by MarkusD on 14 December 2012 - 09:17 AM in I have a question

Can you draw a scheme of your case?(tables structure)




#4701 Trying to implement the library for interdependent select lists

Posted by MarkusD on 13 December 2012 - 03:48 PM in I have a question

Hello,

I am trying to do just as it is written on the library, and I have an identical case, countries, states and cities and another table, so it should be straightforward, yet .. I am not coming on :wacko:

I have the 3 tables:

countries,

regions

towns



then I have another table called attributes which has, as foreign keys, the primary keys of each of these 3 tables, id_country, id_region, id_town

Then the names of the dropdowns are:

countries, for countries

regions, for regions

towns for cities

And also the tables for countries states and cites are interrelated the same way that it is shown in the library.

I have then the following code:

  $crud->set_relation('id_country', 'country', 'name_country'); 
  $crud->set_relation('id_region', 'regions', 'name_region');  
  $crud->set_relation('id_town', 'towns', 'name_town'); 
 
 
  $this->load->library('gc_dependent_select');
 
  
 
  $fields = array(
 
  // first field:
    'countries' => array( // first dropdown name
	  'table_name' => 'countries', // table of country
	  'title' => 'name_country', // country title
	  'relate' => null // the first dropdown hasn't a relation
    ),
 
    // second field
    'regions' => array( // second dropdown name
	  'table_name' => 'regions', // table of state
	  'title' => 'name_region', // state title
	  'id_field' => 'id_region', // table of state: primary key
	  'relate' => 'id_country', // table of state: id_pais es la foreign key de paises
	  'data-placeholder' => 'select state' //dropdown's data-placeholder:
   
    ),
   
   
    // third field. same settings
    'towns' => array(
	  'table_name' => 'towns',
	  'order_by'=>"name_town DESC",  // string. It's an optional parameter.
	  'title' => 'id: {id_town} / city : {name_town}',  // now you can use this format )))
	  'id_field' => 'id_town',
	  'relate' => 'id_region',
	  'data-placeholder' => 'select city'
    )
    );
 
 
 
  $config = array(
    'main_table' => 'atributes',
    'main_table_primary' => 'id_atribut',
    #"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/', 'atributos_Copy'/'atributs_code'
    "url" =>base_url() . '__atributos_Copia__' .'/' .'__atributos_codigo__'. '/',
  );
 
 
  $categories = new gc_dependent_select($crud, $fields, $config);
 

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

I am not sure if I have interpreted the sample correctly, but what happens is that when I click on the pencil for example to update the data, it takes 3 minutes to open the panel and the select lists are not interconnected, if I move one, the other doesnt notice, also the text editor is gone, there is no formatting headers etc, so the page is very much screwed, I dont know if I have to replace the "main_table" and "table_name" by the actual name of MY tables, but I did that and made no difference.



#4695 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 13 December 2012 - 11:00 AM in Extra coding / Plugins

.



#4605 The editor for Medium Text features are gone

Posted by MarkusD on 06 December 2012 - 09:52 AM in I have a question

SOLVED


I suspect the reason is that FTP program makes mistakes when uploading files, sometimes it misses one out of some thousands, and you are screwed as you don't know why.

so I decided to delete everything and redo. It worked.

Thank you


Markus

===================================

Hello

In one of the panels I created everything worked well, the fields that in the table were set as Medium Text, would show up in the panel as a large text field with all the smilies,and formatting icons, you know the tiny_mce etc

I have reproduced the exact same files in another web, and I am not getting the formatting icons, only an empty text field. Why is that? where is that that controls that?

I have the most basic configuration and I am only using one table in the db



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

class Al_panel_c extends CI_Controller {

function __construct()
{
parent::__construct();

$this->load->library('grocery_crud');
$this->load->library('image_moo');
}

public function index()
{
;
}

public function content()
{
$crud = new grocery_CRUD();
$crud->set_subject('Content');
$crud->set_table('content');


# ++++++++++++++++ LOAD IMAGES RESIZING ++++++++++++++++++++++++++++++++++++

$crud->set_field_upload('pic1','images'); #
$crud->set_field_upload('pic2','images'); #
$crud->set_field_upload('pic3','images'); #
$crud->set_field_upload('pic4','images'); #
$crud->set_field_upload('pic5','images'); #





$crud->callback_after_upload(array($this,'resize')); #



$output = $crud->render();

$this->_example_output($output);

}




function resize($uploader_response,$field_info, $files_to_upload)
{

$thumb_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;


$this->image_moo->load($thumb_uploaded)->resize(400,300)->save($thumb_uploaded,true);





if($this->image_moo->error) {

print $this->image_moo->display_errors();
}

return true;

}








function _example_output($output = null)

{
$this->load->view('our_template.php',$output);
}

}


In addition I am finding out that the Save and go back to list is not working.
The Save button does save, but after that, instead of the green message your data has been added ..i get an ugly unformatted message saying the same thing.

something really weird is going on here...



#4588 [updated 24/11/2012] Dependent dropdown (library)

Posted by MarkusD on 04 December 2012 - 07:08 PM in Extra coding / Plugins

Thank you very much, extraordinary job! I have not tried yet but it is an amazing achievement, precisely what so many of us were looking for! I will try it tomorrow and I hope I do well.

congratulations!



#4584 callback function

Posted by MarkusD on 04 December 2012 - 02:51 PM in I have a question

Hello everybody,


I am confronted with the following.

I have interdependent select lists in my webform and they work fine with JQUERY

but now, I need the same utility in the CRUD panel.

I dont know how to go about that.

I am thinking about using a callback function.., that is, when I select the first option from the first select list, then according to that previous selection, the second select lists, populates. Like I said, it works on the users interface on the web, but...how do I do that in the CRUD panel?

thank you



#4420 Different users login in?

Posted by MarkusD on 24 November 2012 - 08:58 AM in I have a question

Hello,

I have been studying your code to understand it, but there is something I dont grasp very well.

When a user lands on the page, because the page can already know the name of the User, (you mark it as User = 2) then it goes to a function that makes a query with that ID and returns a list of rows. That is fine. What I dont understand is how you are actually getting the values from the 3rd and 4th segments, because at that point, there are no values in there. There are only 2 segments, controller and function, but not a third segment for edit, or delete and not a fourth segment for id.


var $user = 2;
function pr() {
// validation init
$this->security(); #Before loading any table, we redirect to a function which will select the rows that correspond Only to the User. That is correct and fine.

# Now we have returned from the function and we have our own data to create our table
$crud = new grocery_CRUD();
$crud->set_table('my_files');
$crud->where('user_id', $this->user);
$output = $crud->render();
$this->_example_output($output);
}




function security() {

# but here, I dont see there is any value in the 3rd segment. On arriving there is only the controller and the function, so segments 1 and 2.

# when the user clicks on Edit or Delete or Add, then comes the 3rd segment and it is show in the URL, but only after clicking.
	 $method = $this->uri->segment(3);
	 if ($method == "edit" or $method == 'update_validation' or $method == 'delete') {

# Where is the value of a Fourth segment after clicking Edit or Delete? I dont get any in my page.

# You are assuming it would be the ID, but, it does not appear in my URL. I can show it in the page like Welcome John to the Administration Panel.
				 $id = $this->uri->segment(4);
				 $result = $this->db->get_where('my_files', array('id' => $id), 1)->row();
				 if ($result->user_id != $this->user)
				 {
						 echo "You don't have access";
						 exit;
				 }
				 else return true;
		 }
}

So, the question is:


Wouldn't you instead, when the Page is loading, use the $username to retrieve only the table that corresponds to that user? If I correctly understand your code, when the page loads, all the rows of everybody are loaded.

That is, if my understanding is correct, it is much easier to simply do, as you say:

$crud->set_table('my_files');
$crud->where('user_id', $this->user);

what is the reason that you go to do the rest of the code about segments 3 and 4 and etc?



#4372 Different users login in?

Posted by MarkusD on 22 November 2012 - 10:19 AM in I have a question

Hi, MarkusD and welcome to the forum!
maybe your solution is here:
http://www.grocerycr...ata-in-a-table/


Thank you very much, I will study that!



#4365 Different users login in?

Posted by MarkusD on 22 November 2012 - 08:54 AM in I have a question

Hello,



Would it be possible that the administration panel, where the table and rows are can have access for different users and each user just gets his own table that he can modify?

That is, what we have now is an administration page, a CRUD page where we can upload pictures, write text etc, but only for me. The scenario is that you have a website and you let other people log in, each with their different account and each of them would have access to only their own table with their own data. Of course, all can log at the same time from different places in the world.

I can imagine of course that that would be a matter of session_id, where each user gets his, and with that session_id then the specific data are retrieved for each user, I am imagining all this, but is it really feasible or it would be too difficult to do with CRUD ?


thanks