Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of adding Statistical function to phpcms

Shulou Source: shulou.com Published: 2022-06-02 05:00:25 10月04日 Update

Editor to share with you how to add statistical functions to phpcms, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

How does phpcms count?

PHPCMS adds the whole site access statistics function

The current PHPCMS V9 version does not have the function of site-wide access statistics, but what if you do not want to use a third-party plug-in? Here is attached for you a PHPCMS implementation of the site-wide page access statistics tutorial.

The first step is to customize the function code of access statistics

1. Open the extention.func.php file

File path: phpcms/libs/functions/extention.func.php

2. Type the following code in extention.func.php

Function getNewsContent ($id) {session_start (); $log = 'log.txt';if (! $handle = fopen ($log, "a +)) {echo' log file opening failed'; exit ();} if (! fwrite ($handle,session_id (). Chr (13)) {echo 'data write failure'; exit ();} fclose ($handle); $file = file_get_contents ($log); $content = explode (chr (13), $file) Echo "visit Statistics:". (count ($content)-1). ";}

The second step is to invoke the tag in the html template.

If I need to add visit statistics to the bottom of the website:

Open file path: phpcms/templates/default/content/footer.html

Add {getNewsContent ($r ['id'])} to footer.html

The effect of access statistics can be realized.

The above are all the contents of the method of adding statistical functions to phpcms. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Statistics functions files methods code content articles paths not so much whole site functions most bottom how to do plug-ins effects tutorials data logs more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Microsoft vpn Shulou Technology Docker