Skip to content

Commit

Permalink
Add visit counter
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidpeywasti committed Jul 29, 2019
1 parent 2edcff4 commit 7593882
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dca/tl_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
'palettes' => array
(
'__selector__' => array('addEnclosure','overwriteMeta'),
'default' => '{title_legend},title,alias,featured;{meta_legend},pageTitle,date,description;{summary_legend},summary;{offer_legend:hide},price,availability,priceValidUntil;{rating_legend},rating_value,rating_count;{product_legend},brand,model,sku,global_ID;{image_legend},singleSRC,overwriteMeta;{related_legend},related;{link_legend:hide},url,target,titleText,linkTitle;{enclosure_legend:hide},addEnclosure;{publish_legend},published,start,stop',
'default' => '{title_legend},title,alias,featured;{meta_legend},pageTitle,date,description;{summary_legend},summary;{offer_legend:hide},price,availability,priceValidUntil;{rating_legend},rating_value,rating_count,visit;{product_legend},brand,model,sku,global_ID;{image_legend},singleSRC,overwriteMeta;{related_legend},related;{link_legend:hide},url,target,titleText,linkTitle;{enclosure_legend:hide},addEnclosure;{publish_legend},published,start,stop',
),

// Subpalettes
Expand Down Expand Up @@ -151,6 +151,14 @@
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'visit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_carpets']['visit'],
'sorting' => true,
'inputType' => 'text',
'eval' => array('disabled'=>true, 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_product']['title'],
Expand Down Expand Up @@ -509,7 +517,7 @@ public function generateProductsRow($arrRow)
$strImage = \Image::getHtml(\Image::get($objImage->path, '60', '60', 'center_center'));
}

return '<div><div style="float:left; margin-right:10px;">'.$strImage.'</div><p><strong>'. $arrRow['title'].'</strong></p><p> Brand: '.$arrRow['brand'] .' &emsp; Model: '. $arrRow['model']. ' &emsp; SKU: '. $arrRow['sku'] .'</p></div>';
return '<div><div style="float:left; margin-right:10px;">'.$strImage.'</div><p><strong>'. $arrRow['title'].'</strong></p><p> Brand: '.$arrRow['brand'] .' &emsp; Model: '. $arrRow['model']. ' &emsp; SKU: '. $arrRow['sku'] . ' &emsp; Visit: '. $arrRow['visit'] .'</p></div>';
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/library/Frontend/Module/ModuleProductDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ protected function compile()
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}

// Update the database
$this->Database->prepare("UPDATE tl_product SET `visit`=`visit`+1 WHERE id=?")
->execute($objProduct->id);

// Overwrite the page title
if ($objProduct->pageTitle)
{
Expand Down

0 comments on commit 7593882

Please sign in to comment.