NEW Increment website counter on each page access in website module
This commit is contained in:
parent
52f80737f5
commit
33917e97b6
@ -423,6 +423,33 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
|||||||
print $content;
|
print $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase the website counter of page access.
|
||||||
|
*
|
||||||
|
* @param int $websiteid ID of website
|
||||||
|
* @param string $websitepagetype Type of page ('blogpost', 'page', ...)
|
||||||
|
* @param int $websitepageid ID of page
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function dolWebsiteIncrementCounter($websiteid, $websitepagetype, $websitepageid)
|
||||||
|
{
|
||||||
|
if (!getDolGlobalInt('WEBSITE_PERF_DISABLE_COUNTERS')) {
|
||||||
|
//dol_syslog("dolWebsiteIncrementCounter websiteid=".$websiteid." websitepagetype=".$websitepagetype." websitepageid=".$websitepageid);
|
||||||
|
if (in_array($websitepagetype, array('blogpost', 'page'))) {
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$sql = "UPDATE ".$db->prefix()."website SET pageviews_total = pageviews_total + 1, lastaccess = '".$db->idate(dol_now())."'";
|
||||||
|
$sql .= " WHERE rowid = ".((int) $websiteid);
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if (! $resql) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format img tags to introduce viewimage on img src.
|
* Format img tags to introduce viewimage on img src.
|
||||||
|
|||||||
@ -271,7 +271,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage,
|
|||||||
$tplcontent .= '</html>'."\n";
|
$tplcontent .= '</html>'."\n";
|
||||||
|
|
||||||
$tplcontent .= '<?php // BEGIN PHP'."\n";
|
$tplcontent .= '<?php // BEGIN PHP'."\n";
|
||||||
$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
|
$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.'); dolWebsiteIncrementCounter('.$object->id.', "'.$objectpage->type_container.'", '.$objectpage->id.');'."\n";
|
||||||
$tplcontent .= "// END PHP ?>\n";
|
$tplcontent .= "// END PHP ?>\n";
|
||||||
|
|
||||||
//var_dump($filetpl);exit;
|
//var_dump($filetpl);exit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user