We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8472
    • 19 Posts
    Has anyone seen a "popular articles" plugin/chunk/hack out there?

    It seems to me that this is a pretty basic CMS feature, but I can’t seem to find a solution.
      • 10449
      • 956 Posts
      I’m not aware of any such thing. It would require that modx has some in-built statistics / counter for each document available, but this is not the case. afaik, modx used to have such a feature in older versions, but it has been dropped at some time. You still see a legacy of this in the edit document menu: the 2nd tab "page settings": checkmark "log visits"...

      It wouldn’t be too hard though to add a hit-counter, either via snippet or plugin. Ditto would then need to somehow fetch these infos via a custom @SELECT command.
        • 8472
        • 19 Posts
        Perhaps Page Hit Counter would work?
          • 7804
          • 80 Posts
          Quote from: editor at Apr 21, 2008, 12:06 PM

          Perhaps Page Hit Counter would work?

          that’s a module for the backend. i don’t think it would help with frontend parsing although maybe this module provides the framework for getting started (i don’t know anything much about it).
            • 3707
            • 241 Posts
            I wrote a snippet to do this a while back using Page Hit Counter stats. The client didn’t want to go with a ’popular articles’ section in the end so I didn’t finish the snippet but it did work. I’ll post the code here but as I said, it’s not finished (though it worked) and I’m not a programmer so I’m sure it could be improved a lot. I know there is a better way to connect to the db but this was a rough script. Just create a new snippet and paste the code in.

            You can change the output to something other than the unordered list I used. Obviously you need to install Page Hit Counter first and I believe you need to check the box ganesh referred to (Log visits (stats) on the Page Settings tab) on documents you want to record stats for, uncheck it for those you don’t want stats for.

            $page = '';
            $dbServer = "localhost";
            $dbDatabase = "db-name";
            $dbUser = "db-username";
            $dbPass = "db-password";
            
            $sConn = mysql_pconnect($dbServer, $dbUser, $dbPass) or die("Couldn't connect to database server");
            $dConn = mysql_select_db($dbDatabase, $sConn) or die("Couldn't connect to database");
            
            	$sql = "SELECT * FROM  modx_page_hit_counter";
            	$rs = $modx->db->query($sql);
            	$count = $modx->db->getRecordCount($rs);
            	if($count < 1) {
            		$page .= "No records found.";
            	} else {
                    // list page hits
                    $sql = "SELECT phc.page_count, sc.pagetitle, page_id FROM modx_page_hit_counter phc, modx_site_content sc WHERE sc.id = phc.page_id ORDER BY phc.page_count DESC, sc.pagetitle ASC LIMIT 5";
                    $rs = $modx->db->query($sql);
                    $page .= '<ul>';
                    while($row = $modx->db->getRow($rs)) {
                        $page .= '<li><a href="[~' .$row['page_id']. '~]">'.$row['pagetitle'].' '.$row['page_count'].'</a></li>';
                    }
                    $page .= '</ul>';
                    }
            return ($page);

              • 8960
              • 150 Posts
              Funny, I just ran across this post today. It describes how to use Google Analytics to push the most popular pages to Google Groups, then Yahoo Pipes, and finally back to your site. It sounds complicated, but it looked easy to do. While that’s a lot more convoluted that a MODx solution, but it might help somebody out. I need it for a static HTML site.

              http://blogoscoped.com/archive/2008-01-17-n73.html
                • 4391
                • 7 Posts
                Quote from: ER at May 02, 2008, 08:28 PM

                Funny, I just ran across this post today. It describes how to use Google Analytics to push the most popular pages to Google Groups, then Yahoo Pipes, and finally back to your site. It sounds complicated, but it looked easy to do. While that’s a lot more convoluted that a MODx solution, but it might help somebody out. I need it for a static HTML site.

                http://blogoscoped.com/archive/2008-01-17-n73.html

                You might be able to use this somehow with FeedX. I want to do the same thing with my blog feed, and I’ve been playing around with FeedX and APIs. Originally, I was going to tie into slimstat, but using Google Analytics looks like a much better idea.