Does anybody know how I can add a web counter written in PHP? #1029
-
|
Hello community. I use a web counter written in PHP called BBClone. I installed the code in the "yellow.php" file, in the root directory. However, if I try to add the code inside other places, like in the "/system/layouts/blog.html" , to track the blog posts, the code does not work, even If I use the two dots to go up to the parent directory ( ../../) By the way, this is the code that I am trying to use in the blog.html |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
|
At first sight BBClone seems very complicated: there are about thirty PHP files alone. Although there is certainly some way to use it within Yellow, it would be a bit strange to use a counter that alone is more complex than the entire CMS: usually Yellow's extensions consist of a single PHP file. Perhaps it would be better to look for a simpler counter first? Also the extension Traffic could perhaps be all that is really needed. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, Mr. Giovanni Salmeri.
Thank you for reading my post and for your reply, it means a lot to me.
Every week I have questions about how to change this or that in the Yellow
CMS, but I avoid to write in the forum because I don't wanna be seen as a
vampire, so, I search internet and try to find a solution, basically
learning with my mistakes and trying again ... but, in this case, I tried
everything I could, that's the reason that I posted my question.
Well, I will forget this for a while, and be happy tracking only the main
page.
I wish you a great week for you and your family.
Peace.
Alexandre.
Em seg., 28 de abr. de 2025, 05:15, GiovanniSalmeri <
***@***.***> escreveu:
… At first sight BBClone seems very complicated: there are about thirty PHP
files alone. Although there is certainly some way to use it within Yellow,
it would be a bit strange to use a counter that alone is more complex than
the entire CMS: usually Yellow's extensions consist of a single PHP file.
Perhaps it would be better to look for a simpler counter first? Also the
extension Traffic <https://github.com/annaesvensson/yellow-traffic> could
perhaps be all that is really needed.
—
Reply to this email directly, view it on GitHub
<#1029 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BAGP4WC6KSGHVH7PKDOMQXL23XPTPAVCNFSM6AAAAAB34VCH3WVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOJWGY4DAOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
What you have done to make the web counter work on the main page, can you copy/paste the code? |
Beta Was this translation helpful? Give feedback.
-
|
Dear developer Anna Svensson, your code worded!! |
Beta Was this translation helpful? Give feedback.
-
|
Hello Alexandre, I wanted to add a view counter to specific pages in my blog and may also have a solution for you. This view counter can be added via the shortcut This code uses the fantastic yellow-settings-file-handling ( The data will look like: /blog/ur-spiel: 1333
/blog/jarmo: 903
/blog/der_abgrund: 886
/blog/popelfinger: 1075You may want to modify the text template Here is my <?php
class YellowViewcounter
{
const VERSION = "0.0.1";
public $yellow;
protected $viewCounterFile = 'viewcounter.ini';
public function onLoad($yellow)
{
$this->yellow = $yellow;
}
public function onParseContentElement($page, $name, $text, $attributes, $type)
{
$output = null;
// text template
$displayText = '<p>Dieser Beitrag wurde %c% mal aufgerufen.</p>';
list($displayType) = $this->yellow->toolbox->getTextArguments($text);
if ($name == "counter" && ($type == "block" || $type == "inline") and $page->isActive()) {
$viewCount = 1;
$location = $page->getLocation();
$counterData = $this->loadViewCounter();
if ($counterData->isExisting($location)) {
$viewCount = $counterData->get($location) + 1;
$counterData->set($location, $viewCount);
} else {
$counterData->set($location, $viewCount);
}
$this->saveViewCounter($counterData);
$output = str_replace('%c%', $viewCount, $displayText);
}
if ($displayType == 'hidden') return null;
return $output;
}
public function saveViewCounter($counterData)
{
$fileName = $this->yellow->system->get("coreExtensionDirectory") . $this->viewCounterFile;
$fileData = $this->yellow->toolbox->readFile($fileName);
$fileData = $this->yellow->toolbox->setTextSettings($fileData, '', '', $counterData);
$this->yellow->toolbox->writeFile($fileName, $fileData);
}
public function loadViewCounter()
{
$fileName = $this->yellow->system->get("coreExtensionDirectory") . $this->viewCounterFile;
$fileData = $this->yellow->toolbox->readFile($fileName);
$data = $this->yellow->toolbox->getTextSettings($fileData, '');
return $data;
}
}There is potential to optimize the code (don't count logged in users, etc.), but i fits my need and maybe yours too. Take care! |
Beta Was this translation helpful? Give feedback.

At first sight BBClone seems very complicated: there are about thirty PHP files alone. Although there is certainly some way to use it within Yellow, it would be a bit strange to use a counter that alone is more complex than the entire CMS: usually Yellow's extensions consist of a single PHP file. Perhaps it would be better to look for a simpler counter first? Also the extension Traffic could perhaps be all that is really needed.