Jump to content


MarkusD

Member Since 22 Nov 2012
Offline Last Active Jan 12 2013 09:04 PM
-----

Posts I've Made

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

16 December 2012 - 10:01 PM

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!!

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

16 December 2012 - 09:54 PM

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);
}

}

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

16 December 2012 - 09:52 PM

show url to the controller and function


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

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

16 December 2012 - 09:27 PM

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

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

16 December 2012 - 08:44 PM

-