Creating a TokkoSearch object

Data loaded from the QueryString:
$auth = new TokkoAuth('a289c133348c53c870cf2ae21cc513a238ea684a');
$tokko_search = new TokkoSearch($auth);
Getting data from within the code
Executing the query:
$tokko_search->do_search();


Getting Search Parameters

Getting the search data string:
echo "Data =>". json_encode($tokko_search->search_data);
Data =>{"current_localization_id":1,"current_localization_type":"country","price_from":1,"price_to":999999999999,"operation_types":[1],"property_types":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"currency":"USD","filters":[]}

Getting the current page number:
Can be set as a Querystring variable: 'page'.
echo "Current page =>". $tokko_search->get_current_page();
Current page =>1

Getting the amount of results per page:
Can be set as a Querystring variable: 'limit'.
echo "Items per page =>". $tokko_search->get_current_page_limit();
Items per page =>20

Getting the order by clause used in the query:
Can be set as a Querystring variable: 'order_by'.
echo "Order by =>". $tokko_search->get_search_order_by();
Order by =>price

Getting the order clause used in the query:
Can be set as a Querystring variable: 'order' (Options are "asc" or "desc").
echo "Order =>". $tokko_search->get_search_order();
Order =>desc

Getting the language used for the results:
Can be set as a Querystring variable: 'lang'.
echo "Results language =>". $tokko_search->auth->get_language();
Results language =>es_ar

Search results meta information

Getting the total amount of pages:
echo "Result pages => ". $tokko_search->get_result_page_count();
Result pages => 62

Getting the total amount of properties in the result set:
echo "Result count => ". $tokko_search->get_result_count();
Result count => 1224

Iterating over the result properties

Example, printing the reference codes and cover picture thumb url:
foreach ( $tokko_search->get_properties() as $prop){
    echo "<BR>" . $prop->get_field('reference_code') ." - ". ($prop->get_cover_picture()->thumb ?: "No picture");
}

IAP2348945 - https://static.tokkobroker.com/thumbs/107453980350029517830881044057399767328977166812171408051815209923090477715046_thumb.jpg
IBU3790 AP2589403 - No picture
IHO2445877 - https://static.tokkobroker.com/thumbs/51620785137780797105649356278298517529683028758346204306704492003362609384216_thumb.jpg
IAP2661056 - https://static.tokkobroker.com/thumbs/94962819971185444994693301196359941350263787668319893716794230757364390354980_thumb.jpg
IAP2576145 - https://static.tokkobroker.com/thumbs/34224303602213009332227271441351206023957741293372524287076209810758397177833_thumb.jpg
IBU0011 AP447716 - https://static.tokkobroker.com/thumbs/49342353665365574003228704639228597960955426694655870694196756776719306722871_thumb.jpg
IBU0011 AP447735 - No picture
IBU7214 AP549117 - https://static.tokkobroker.com/thumbs/42742649554175885781230482437659902504611039878960622586349693428395231078700_thumb.jpg
IBU7214 AP549126 - https://static.tokkobroker.com/thumbs/642211950333934263692193622563613071762900521154644148028135894437006565061_thumb.jpg
IBU7214 AP549127 - https://static.tokkobroker.com/thumbs/88343408850670973287110734379078761427896600093087162650590761221188686724585_thumb.jpg
IBU7214 AP549129 - https://static.tokkobroker.com/thumbs/33537206485859514469418148161503361734358093719392597355900821543819048375024_thumb.jpg
IBU7214 AP549130 - https://static.tokkobroker.com/thumbs/67042745877802205797122182150166965199026979369261738052787531716767253883020_thumb.jpg
IBU7214 AP549131 - https://static.tokkobroker.com/thumbs/102666041963352803762490179416817299623134760494751407186027726319029804647872_thumb.jpg
IBU7214 AP549132 - https://static.tokkobroker.com/thumbs/14922703110343402474905116405134999657766700748549053273343202952728611485681_thumb.jpg
IBU7214 AP549133 - https://static.tokkobroker.com/thumbs/90465748383586234432104299260876284566846137389747555502727172124877989011913_thumb.jpg
IBU7214 AP549134 - https://static.tokkobroker.com/thumbs/109290859038853993579268877358661038760969180022856480131584632769702923290030_thumb.jpg
IBU7214 AP549135 - https://static.tokkobroker.com/thumbs/27557501520095786013788716425370341911229104537588169920072736686390680497261_thumb.jpg
IBU7214 AP549136 - https://static.tokkobroker.com/thumbs/19818117728119121830130476109612864391663079953398278268542853767648430117202_thumb.jpg
ILA1085471 - No picture
IAP1121921 - https://static.tokkobroker.com/thumbs/75854322929622185203376068655494263424687514727502176856227209275821560646147_thumb.jpg

Getting a single property

Must have a TokkoAuth
Getting a property from it's reference_code and printing it's id and possible operations.
$prop = new TokkoProperty('reference_code', 'GHO1203', $auth);
echo $prop->get_field('id') . " - " . implode("|", $prop->get_available_operations());
No propertyNo property -

Getting a property from it's id and printing it's reference_code and the operation 'Sale' in 'USD'. Note: The operation must be in the language of the search, in this case "Venta"
$prop = new TokkoProperty('id', '1203', $auth);
echo $prop->get_field('reference_code') . " - " . implode("|", $prop->get_operations('Venta', 'USD'));
No propertyNo property -

Making the search box

Select box for country selection
Parameters are: id, name, classes, default_choice_id, text_for_no_selection
We will pre select argentina (id=1)
   $countries = new TokkoCountries();
   $countries->deploy_select_box('countries_select_box', 'countries_select_box', '', '1', 'Seleccione un pais');


Select box for state selection (In this case, for argentina) Parameters are: country_id, name, classes, default_choice_id, text_for_no_selection
   $states = new TokkoStates("1");
   $states->deploy_select_box('states_select_box', 'states_select_box', '', '', 'Seleccione una provincia');


Ajax connection for the countries select box and the states select box.
New selects will be deployed for example coherence
JQuery must be configured properly
$countries2 = new TokkoCountries();
$countries2->deploy_select_box('countries_select_box2', 'countries_select_box2', '', '', 'Seleccione un pais');
$states2 = new TokkoStates();
$states2->deploy_select_box('states_select_box2', 'states_select_box2', '', '', 'Seleccione una provincia');
$states2->connect($countries2);
$states2->ajax_deploy();


Select box for division selection (In this case, for Capital Federal)
And another one for Belgrano Parameters are: id, name, classes, default_choice_id, text_for_no_selection
$divisions = new TokkoDivisions("146");
$divisions->deploy_select_box('divisions_select_box', 'divisions_select_box', '', '', 'Seleccione un barrio');
$divisions2 = new TokkoDivisions(null, "24682");
$divisions2->deploy_select_box('divisions_select_box2', 'divisions_select_box2', '', '', 'Seleccione un sub-barrio');


Select boxes tree full
$countries = new TokkoCountries();
$countries->deploy_select_box('country', 'country', '', '', 'Seleccione un pais');
$states = new TokkoStates();
$states->deploy_select_box('states', 'states', '', '', 'Seleccione una provincia');
$divisions = new TokkoDivisions();
$divisions->deploy_select_box('divisions_1', 'divisions_1', '', '', 'Seleccione una division');
$divisions2 = new TokkoDivisions();
$divisions2->deploy_select_box('divisions_2', 'divisions_2', '', '', 'Seleccione una division');
$divisions3 = new TokkoDivisions();
$divisions3->deploy_select_box('divisions_3', 'divisions_3', '', '', 'Seleccione una division');
$divisions4 = new TokkoDivisions();
$divisions4->deploy_select_box('divisions_4', 'divisions_4', '', '', 'Seleccione una division');
$divisions4->connect($divisions3);
$divisions3->connect($divisions2);
$divisions2->connect($divisions);
$divisions->connect($states);
$states->connect($countries);
$divisions4->ajax_deploy();
$divisions3->ajax_deploy();
$divisions2->ajax_deploy();
$divisions->ajax_deploy();
$states->ajax_deploy();


Select boxes tree full, same as before, but with the option of hiding the childs.
Works only if it is within a container like a DIV or a LI beacuse that's what
it should hide, also we give 2 elements ids (inputs, that can be hidden)
where we will store the location information, one for the id, and another for the type.
We should put a lot of divisions so the ajax_connect takes the burden of saving the id and type.
type = <input id="location_type">
location = <input id="location_id">
<?
$countries = new TokkoCountries();?>
<div><?$countries->deploy_select_box('_country', '_country', '', '', 'Seleccione un pais');?></div><?
$states = new TokkoStates();?>
<div class="hidden"><?$states->deploy_select_box('_states', '_states', '', '', 'Seleccione una provincia');?></div><?
$divisions = new TokkoDivisions();?>
<div class="hidden"><?$divisions->deploy_select_box('_divisions_1', '_divisions_1', '', '', 'Seleccione una division');?></div><?
$divisions2 = new TokkoDivisions();?>
<div class="hidden"><?$divisions2->deploy_select_box('_divisions_2', '_divisions_2', '', '', 'Seleccione una division');?></div><?
$divisions3 = new TokkoDivisions();?>
<div class="hidden"><?$divisions3->deploy_select_box('_divisions_3', '_divisions_3', '', '', 'Seleccione una division');?></div><?
$divisions4 = new TokkoDivisions();?>
<div class="hidden"><?$divisions4->deploy_select_box('_divisions_4', '_divisions_4', '', '', 'Seleccione una division');?></div><?
$divisions5 = new TokkoDivisions();?>
<div class="hidden"><?$divisions5->deploy_select_box('_divisions_5', '_divisions_5', '', '', 'Seleccione una division');?></div><?
$divisions5->connect($divisions4);
$divisions4->connect($divisions3);
$divisions3->connect($divisions2);
$divisions2->connect($divisions);
$divisions->connect($states);
$states->connect($countries);
$divisions5->ajax_deploy(true, 'location_type', 'location_id');
$divisions4->ajax_deploy(true, 'location_type', 'location_id');
$divisions3->ajax_deploy(true, 'location_type', 'location_id');
$divisions2->ajax_deploy(true, 'location_type', 'location_id');
$divisions->ajax_deploy(true, 'location_type', 'location_id');
$states->ajax_deploy(true, 'location_type', 'location_id');
type = location =


Or we can use the helper class to create a full tree.
Full parameters list:
$id, $default_select_text, $input_id_for_type=null, $input_id_for_id=null, $starting_id=null, $starting_box='country', $depth=10, $container_type='div', $hide_childs=true
Example for a full tree:
$search_form = new TokkoSearchForm();
$search_form->deploy_location_tree('location_tree1', "Seleccione una opcion", "location_tree1-type", "location_tree1-id");


Example for a tree with pre-selection_argentina:
$search_form = new TokkoSearchForm();
$search_form->deploy_location_tree('location_tree2', "Seleccione una opcion", "location_tree2-type", "location_tree2-id", "1");


Example for a tree starting in Capital federal that only lists barrios/localidades:
Also in this example we will use an UL. so we specify the item_container as LI.
$search_form = new TokkoSearchForm();
echo '<ul>';
$search_form->deploy_location_tree('location_tree3', "Seleccione una opcion", "location_tree3-type", "location_tree2-id", "146", "state", 2, 'li');
echo '</ul>';


Deploying an operation type selector.
Requires an auth object for the name of the operations language.
Full parameters:
$id, $selection_text='', $availables=[1,2,3], $classes="", $default=null, $type="select"
3 styles can be deployed automagically:
$search_form = new TokkoSearchForm($auth);
$search_form->deploy_operation_types_selection('operation_selector', "Seleccione una operacion");
echo "<BR>";
$search_form->deploy_operation_types_selection('operation_selector2', "Operacion:", [1,2], "", 1, "radiobutton");
echo "<BR>";
$search_form->deploy_operation_types_selection('operation_selector3', "Operaciones:", [1,2,3], "", [1,2,3], "checkbox");

Operacion: Venta   Alquiler  
Operaciones: Venta   Alquiler   Alquiler Temporario  

Deploying a currency selector.
Full parameters:
$id, $selection_text='', $availables=["USD", "ARS"], $classes="", $default=null, $type="select", $container=null
2 styles can be deployed automagically:
$search_form = new TokkoSearchForm();
$search_form->deploy_currency_selection('currency_selector', "Seleccione una moneda");
echo "<BR>";
$search_form->deploy_currency_selection('currency_selector2', "Moneda:", ["USD","ARS"], "", "ARS", "radiobutton");

Moneda: USD   ARS  

Deploying a price range selector.
Full parameters:
$id, $selection_text=['', ''], $ranges=[30000,50000,100000,150000,200000,250000,300000,350000,400000,450000,500000,1000000,2000000,3000000,4000000,5000000], $classes="", $default=null
$search_form = new TokkoSearchForm();
$search_form->deploy_price_range_selection('price_range', ["minimo", "maximo"]);
  

Deploying a property type selector.
Requires Auth
Full parameters:
$id, $selection_text='', $classes="", $default=null, $type="select"
2 styles can be deployed automagically, first one is repeated with and without filters:
$property_types = new TokkoPropertyTypes($auth);
$property_types->deploy_selection('property_types_select_box', "Seleccione un tipo de propiedad");
$property_types = new TokkoPropertyTypes($auth, [1,2]);
$property_types->deploy_selection('property_types_select_box2', "Seleccione un tipo de propiedad");
echo "<BR>";
$property_types->deploy_selection('property_types_checkbox', "Tipo de propiedad:", "", [1], "checkbox");

Tipo de propiedad:
Go to the next page(Full search form)->