PHP/Example of overriding the default behavior of the class to display data in html

Материал из Laximo
Перейти к: навигация, поиск
Эта страница является переводом страницы PHP/Example of overriding the default behavior of the class to display data in html. Перевод выполнен на 100%.

Другие языки:
English • ‎русский

Example of overriding the default behavior of the classes to display data in html

Standard problem necessary to solve - integration with the online shop.
To solve it, a DrawDetailCellValue function, that displays the detail's table cell content, gets overridden in the details list.
If the function displays the column cart, it embeds its link for adding the detail to the cart.
For other columns the display algorithm by default is used.

In the following sample you can see the integration with VirtueMart via special page
that checks the presence of the detail in the VirtueMart online shop, and register it prior adding, in case of its absence.

class GuayaquilDetailsListEx extends GuayaquilDetailsList
{
	function DrawJavaScript()
	{
		$this->AppendJavaScript(JPATH_SITE.DS.'components'.DS.'com_guayaquil'.DS.'views'.DS.'jquery.colorbox.js');
		$this->AppendCSS(JPATH_SITE.DS.'components'.DS.'com_guayaquil'.DS.'views'.DS.'colorbox.css');
 
$html = '<script type="text/javascript"> ';
		$html .= 'jQuery.noConflict(); ';
		$html .= 'jQuery(document).ready(function($){ ';
		$html .= '$(\'a.g_cart\').colorbox(); ';
		$html .= '}); ';
		$html .= '</script> ';
 
$html .= parent::DrawJavaScript();
 
return $html;
	}
 
function DrawDetailCellValue($detail, $column, $visibility, $replacement, $haschild, $isArray)
	{
		//If it's a column with "add to cart" button, override its content
		if ($column == 'cart')
		{
		$link = 'index2.php?option=com_guayaquil&no_html&view=addtocart&r='
                .strtr(base64_encode('o@'.$this->getProperty($detail, 'oem', $isArray)
                .'|n@'.$this->getProperty($detail, 'name', $isArray).'|p@'.$this->getProperty($detail, 'price', $isArray)), '+/', '-_');
 
			return '<a class="g_cart" href="'.$link.'">
                               <img class="g_addtocart" src="'.$this->cartimage.'" width="22" height="22"></a>';
		}
 
//Use standard formatting for the rest columns
		return parent::DrawDetailCellValue($detail, $column, $visibility, $replacement, $haschild, $isArray);
	}
}

See also

Functions of Laximo web services

General information

Work principles Security Catalogs localization Catalogs update Error handling
Laximo.OEM Catalog search ListCatalogs,GetCatalogInfo
Vehicle search FindVehicleByVIN, FindVehicleByFrame, FindVehicleByFrameNo, FindVehicle, GetWizard2, GetWizardNextStep2, FindVehicleByWizard2, GetVehicleInfo, ExecCustomOperation
Unit search ListUnits, ListCategories, GetFilterByUnit, GetUnitInfo
Searching details in the unit ListDetailByUnit, ListImageMapByUnit, GetFilterByDetail
Quick search of details ListQuickGroup, ListQuickDetail
Laximo.Aftermarket Parts search FindOEM, FindReplacements, FindDetail, FindOEMCorrection
Manufacturer ManufacturerInfo, ListManufacturer
Libraries and samples of Laximo web-services use
PHP
Download
the library for PHP
Library use samples Change of the behavior and appearance of the catalog elements
GuayaquilExtender
Examples of overriding the default behavior of classes to display the data in html
Example of crosses obtainment with LaximoAftermarket
Work with catalogs in the context of catalogs list's display
Скачать библиотеку ASP.NET ASP.NET Guayaquil library
Варианты внедрения сервисов Laximo в 1С

Related categories