PHP Examples

PHP: examples of integration

Introduction

yacht4web provides a technology called search engine (search engine) that allows access to two methods that are list of ads And the viewing boat ad. Both are customizable and available in 9 languages.
To integrate with your site you can choose two technologies, Embedded Http Request method described in this section or the more complex but versatile REST APIs.

How to read the list of ads

This method is the mostù simple and quick and allows you to include in your ad listing site, with minimal intervention,
Is to create a PHP file that contains your header (header), a navigation bar (toolbar) and the foot of the page (footer)
Inside the body then we will search engine by yacht4web. The colours and many parameters are configurable through the section, in the user account.


Example of integration announcements list

<!-- your Header ----->
<link href="http://cdn.yacht4web.com/css/1205/ywEngine.css" rel="stylesheet" type="text/css" />

<!-- your Navigation Bar ----->

<!-- Yacht4web engine core ----->
<div>
<?php
 error_reporting(~0); ini_set('display_errors', 1); // <-- only for debug

 function _add($sz,$szAdd) {
	if (strlen($sz)) $sz=$sz."&";
	$sz=$sz.$szAdd;
	return $sz;
 }

 $appId='[appid]';  // yacht4web appId key
 $idLang=isset($_GET["lang"])?$_GET["lang"]:"it";  // Choose ads language: en,fr,it,de,es,cn,ru,pt,ar

 // Get query params
 $szQuery=$_SERVER['QUERY_STRING'];
 if (!strstr($szQuery,"appid=")) $szQuery=_add($szQuery,"appid=".$appId);
 if (!strstr($szQuery,"nohf=")) $szQuery=_add($szQuery,"nohf=1");
 if (!strstr($szQuery,"_order=")) $szQuery=_add($szQuery,"_order=SHIP%20ASC");
 
 $url= "http://".$idLang.".yacht4web.com/srch?".$szQuery;
 $data = file_get_contents($url);
 echo $data;
?>
</div>
<!-- your Footer  ----->


Highlights
Integrate the list is quick, but some points are needed to allow to structure yacht4web the service properly.

  1. Include the default style ywEngine.css as shown in the example
    The style is decided in part by classes in the file and in part by a tag <style/> under custom colors chosen in the motor setup.
  2. Indicate your code AppID within the call.
  3. Indicate the page/script in your site contains the search engine
    It is necessary to understand that the site is located on your server, but the list of boats are generated dl yacht4web.
    In order to properly build links for navigation, yacht4web needs to know the name of your page URL (the PHP page that contains yacht4web code).
    It is possible to indicate absolute URL (e.g. http://<your site>/search.php) related (e.g./search.php).
  4. Indicate the page/script in your site contains the boat display

All arguments/parameters are passed to the application yacht4web/srch: make sure you don't use " internally " parameters with the same name, used by the search engine (e.g. yacht4web appid or w).
An important parameter è lang containing two letters corresponding to the language from display.


Form (form) search/search
Through the search engine's setup, you can indicate if you wish to have a search form operated by yacht4web.
Alternatively you can indicate through the filter parameter of the ads that want to extract
The specifics of possible parameters find described here

How to see an ad

The boat can be viewed in two formats

  • strict-mode short tab (default mode)
  • detail-detailed card: give as parameter mode = dett

The parameter head = 1 indicates that you want the heading of the company.
The parameter nohf = 1 indicates that you do not want the standard html header yacht4web.
The parameter lang the desired language

<?php

 $appId='[appId]';	// Id User
 $idLang=isset($_GET["lang"])?$_GET["lang"]:"it";	// Choose language: en,fr,it,de,es,cn,ru,pt,ar
 $idBoat=isset($_GET["id"])?$_GET["id"]:0;	// idBoat 

	error_reporting(~0); ini_set('display_errors', 1); // <-- remove  after test

	if ($idBoat>0) {
		$url= "http://".$idLang.".yacht4web.com/boatc?appid=".$appId."&id=".$idBoat;
        $url.="&mode=dett&head=1&nohf=1";
		$data = file_get_contents($url);
		echo $data;
		} else {
			printf("no boat selection");
		}
?>