SlimStat Plugin for MODx
Mark Kaplan and I spent less than an hour working on an alternate statistics implementation for MODx, as the current one is starting to show its age and is not as efficient as it could be. We developed our solution around the light weight and smart SlimStat statistics package from Stephen Wettone.
Here is how to get it up and running:
- Download SlimStat
- Extract files to local drive and then upload them to /assets/plugins/ of your web-space.
- Now point your browser to its location e.g. http://mydomain.com/assets/plugins/slimstat/.
- Follow the installation process through their nice simple installer.
- When installed, login to your MODx manager.
- Go to Resources -> Manage Resources and click on Plugins tab.
- Create new Plugin
- Enter this code inside it:
@include_once( $_SERVER["DOCUMENT_ROOT"]."/assets/plugins/slimstat/inc.stats.php" ); - Click on System Events tab.
- Select/Mark the OnWebPagePrerender checkbox
- Hit Save.
THAT'S IT! 
Now you might ask your MSN/Yahoo/AOL buddies to visit your site, and you should see hits in your SlimStat statistics pages. You can access your stats by pointing your browser to http://mydomain.com/assets/plugins/slimstat/.
Until next time, good bye and take good care of yourself and the people around you.
Comments:
LOL, just have to wipe the coffee off my screen after reading your age note. Regarding the built in stats of Mambo/Joomla, modX is way better... ;) Once more surprised by you guys!
I'll definitely try this !
I just wish there were more than 24 hours in a day There is just so much I want to get stuck into, learn and make use of
I just wish there were more than 24 hours in a day There is just so much I want to get stuck into, learn and make use of
Just had to use the path as instructed in Slimstat, the code provided above got me a MODx parse error... Probably a path problem with my particular server configuration.
I'm running MODx 0.9.2.1 on WindowsXP SP2, with Apache 2 and PHP 4.4.0.
This one is to update the ip-to-country data:
http://reverb.madstatic.com/blog/2006/04/02/countryupdate-my-first-plugin-for-slimstat/
This one is to allow ip-to-city tracking:
http://reverb.madstatic.com/blog/2006/06/09/tracking-cities-with-slimstat/
This one is to plot visitors onto a google map (requires city tracking):
http://reverb.madstatic.com/blog/2006/06/09/gmapped-mapping-plugin-for-slimstat/
i presume this has something to do with the server since all the sites i've installed this on my servers work fine - this is on a client's server.
trying to check the stats yields a page telling me to add the code to the pages, which i have, following the instructions above. do i need create a new db rather than use the old one? maybe add a prefix to the tables for this install?
thank you.
Easy to use, and very easy to intergrate into modx. Luv it..
If only we it could show document titles instead of (index.php?id=X) that would have been everything u could ever want in a stat plugin.
But yea we cant have it all can we? ^_^
the download server (http://wettone.com/code/slimstat#download) doesn't work... Is there any other place to get the plugin from? It's very importent to me, so I'll be very thankful for any halp.
the download server (http://wettone.com/code/slimstat#download) doesn't work... Is there any other place to get the plugin from? It's very importent to me, so I'll be very thankful for any halp.
I did a little work to have the pagetitle and id instead of the "/webpage/index.php?id=3" slimstat resource string.
First, add the following lines of code into slimstat's "_config.php":
/** modx variables */
var $modx_table_prefix = 'modx_'; // table prefix
var $modx_home = 1; // id of start-page
The id of your start page is necessary since this is called without the id!
Then add the following code in "inc.stats.php" after line 56 or so (right after where the resource string was fetched):
// make resource string a more readable modx pagetitle
$pos = strpos($stat["resource"], '=');
if ($pos == 0) {
$page = $this->config->modx_home;
}
else
{
$pos2 = strpos($stat["resource"], '&',$pos);
if ($pos2 > 0) {
$len = $pos2 - $pos -1;
$page = substr($stat["resource"], $pos+1, $len);
}
else {
$page = substr($stat["resource"], $pos+1);
}
}
if ($page > 0) {
$modx_query = "SELECT `pagetitle` FROM ".SlimStat::my_esc( $this->config->database )."`.`".SlimStat::my_esc( $this->config->modx_table_prefix )."site_content"."`";
$modx_query .= " WHERE `id` = ".$page;
if ( $result = mysql_query( $modx_query ) ) {
if ( list( $pagetitle ) = mysql_fetch_row( $result ) ) {
$stat["resource"] = $pagetitle." (".$page.")";
}
}
}
Let's say your page with index 6 has a pagetitle called "Contactpage". This results in entries like "Contactpage (6)" instead of "/webpage/index.php?id=6"
Use under your own risk, no warranties!!!
Regards
Heiko
Best...
Heiko
Any help?
Is there a customised MODX version of this?
Taking this straight from the page for Mint integration, I think you can turn off logging for users who are logged into the manager by:
if (!isset($_SESSION['mgrValidated'])) {
@include_once( $_SERVER["DOCUMENT_ROOT"]."/assets/plugins/slimstat/inc.stats.php" );
}
(Although it seems to work for me, I'm never sure about these things...)
You must be logged into the forums to comment. Please login
