Page Data
Solutions > System Tools > Page Data
Status: Stable.
Maintainer: Caveman.
Downloads: pagedata.php.
This script has been replaced by the new info function/command in BoltWire's core. It's still used by some plugins, but those really should be updated to use the new core capabilities.
This script is a fast and powerful tool for setting up a sitewide page counter, and/or many other purposes. It is used in the blog and forum plugins for example to count posts and comments. But the capabilities of this script extend beyond it's uses even there.
Page Counter
Simply enable the plugin and then put something like the following in your skin, footer, or other zone, wherever you want views counted:
Viewed [(pagedata)] times.
This functions retrieves the current page views from a site.public.pagedata, updates that page, and then returns the appropriate number to the current page. This approach is a bit easier on the cpu load as it does not require constant reindexing of pages, caused when page views are stored on the local page. The disadvantage is this script does not delete records when a page is deleted, or reassign records when a page is renamed, though this can be done periodically using the clean parameter (see below).
Page views can be retrieved using normal text var format, ie: {site.public.pagedata::some.page}
Advanced Uses
This little script provides other function that can do a lot of really cool stuff, fast. Basically, store any information about any page anywhere! If using the blog or forum plugins, just enable this script and don't worry about anything else.
If you want to use it for your own purposes, or just want to understand how it works, here's a list of additional parameters it understands:
- page: which page you are going to be storing data about. By default, it is the current page.
- exclude: a csv list of pages you can exempt from processing. Usually it's to exclude a header/footer from post counting.
- data: the page where data is stored. By default it is site.public.pagedata, but it can be any page. To simplify security settings, we recommend placing it in the site.public hierarchy, however.
- value: assign a value to the page. Normally this is a number, like {:comments}.
- count: Set this equal to "forum." and it will count all the entries on the data page that begins with "forum.", ie--the number of posts.
- sum: Set this equal to "forum." and it will add up all the entries on the data page that begins with "forum.", ie--the number of comments.
- output: Set to false suppress the display. Either way the value, count or sum will be saved to page.
This script also has a built in cleaner which can be run periodically (maybe once every day or week by cron) by simply setting [(pagedata clean=true)]. Any entries of pages that do not exist will be deleted.
It also comes with a built in archiver. Simple put [(pagedata archive=true)] and a timestamped copy of the page data will be created at site.public.pagedata.timestamp (or a different location if page= is set). This could be handled by cron periodically to prevent accidental loss of data.
It also sports a lightning fast reporting mechanism which allows you to use regular search parameters (like group, include, exclude, pages) to output a report. By default, pages were sorted by views, but an optional sort=page will sort by page names. To use, set report=true.
Here is an example of one possible report:
<markup>
</markup>
There are many potential uses for this script. If you come up with a good one, let me know. We can add a subpage to this solution.

