Originally Posted by
denniserdmann
Is your work available as extension?
Actually, it is... but it contains a lot of other custom improvements for my own projects... May be I should find time and publish some of it as an extension.
If you familiar with "Extending Contao" concept, just use this:
PHP Code:
// config/config.php
$GLOBALS['BE_MOD']['isotope']['iso_products']['tables'][] = 'tl_content';
$GLOBALS['FE_MOD']['isotope']['iso_productreader'] = 'AppBundle\Module\ProductReaderCustom';
// dca/tl_content.php
if (\Input::get('do') == 'iso_products' && \Input::get('table') == 'tl_content') {
$GLOBALS['TL_DCA']['tl_content']['config']['ptable'] = 'tl_iso_product';
}
// dca/tl_iso_product.php
if (\Input::get('do') == 'iso_products' && !\Input::get('id')) {
$GLOBALS['TL_DCA']['tl_iso_product']['config']['ctable'][] = 'tl_content';
$GLOBALS['TL_DCA']['tl_iso_product']['list']['operations']['edit']['href'] = 'table=tl_content';
array_insert($GLOBALS['TL_DCA']['tl_iso_product']['list']['operations'], 1, [
'editheader' => [
'label' => &$GLOBALS['TL_LANG']['tl_iso_product']['edit'],
'href' => 'act=edit',
'icon' => 'header.svg'
]
]);
}
// class ProductReaderCustom
namespace AppBundle\Module;
use Haste\Http\Response\HtmlResponse;
use Haste\Input\Input;
use Isotope\Model\Product;
class ProductReaderCustom extends ProductReader
{
/**
* Generate module
* @return void
*/
protected function compile()
{
global $objPage;
global $objIsotopeListPage;
$objProduct = Product::findAvailableByIdOrAlias(Input::getAutoItem('product'));
if (null === $objProduct) {
$this->generate404();
}
$arrElements = array();
$objCte = \ContentModel::findPublishedByPidAndTable($objProduct->getProductId(), 'tl_iso_product');
if ($objCte !== null)
{
$intCount = 0;
$intLast = $objCte->count() - 1;
while ($objCte->next())
{
$arrCss = array();
/** @var ContentModel $objRow */
$objRow = $objCte->current();
// Add the "first" and "last" classes (see #2583)
if ($intCount == 0 || $intCount == $intLast)
{
if ($intCount == 0)
{
$arrCss[] = 'first';
}
if ($intCount == $intLast)
{
$arrCss[] = 'last';
}
}
$objRow->classes = $arrCss;
$arrElements[] = $this->getContentElement($objRow, $this->strColumn);
++$intCount;
}
}
$arrConfig = array(
'module' => $this,
'template' => $this->iso_reader_layout ? : $objProduct->getType()->reader_template,
'gallery' => $this->iso_gallery ? : $objProduct->getType()->reader_gallery,
'buttons' => $this->iso_buttons,
'useQuantity' => $this->iso_use_quantity,
'jumpTo' => $objIsotopeListPage ? : $objPage,
'elements' => $arrElements
);
if (\Environment::get('isAjaxRequest')
&& \Input::post('AJAX_MODULE') == $this->id
&& \Input::post('AJAX_PRODUCT') == $objProduct->getProductId()
) {
try {
$objResponse = new HtmlResponse($objProduct->generate($arrConfig));
$objResponse->send();
} catch (\InvalidArgumentException $e) {
return;
}
}
$this->addMetaTags($objProduct);
$this->addCanonicalProductUrls($objProduct);
$this->Template->product = $objProduct->generate($arrConfig);
$this->Template->product_id = $this->getCssId($objProduct);
$this->Template->product_class = $this->getCssClass($objProduct);
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
}
/**
* Generates a 404 page and stops page output.
*/
private function generate404()
{
global $objPage;
/** @var \PageError404 $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($objPage->id);
exit;
}
}
Then, add this in your product reader template (which is iso_reader_default.html5 by default):
PHP Code:
<?php if (!empty($this->config['elements'])) echo implode($this->config['elements']); ?>
Bookmarks