We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • You have to somehow keep track of "hits". Your server logs already do this, so you could parse them; there are a lot of perl scripts that do that. Another is to store the "hits" in a table somewhere, database or a text file or something (which is what this plugin does).

    You could use a hitcount TV that gets incremented via plugin or snippet on each page request, then Ditto could use that TV for filtering.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 5915
      • 21 Posts
      Hi,

      I’d like to say this is a great add-on.
      Just a note: I am running mysql 5 and to start off oddly had a problem and had to create the database info by manually putting in the sql as a previous poster had mentioned.

      But nevertheless, my problem.
      I am having difficulties with calling the id placeholder in the &id=`` parameter.
      I initially call the content of the page with the hit counter from a ditto call, which works fine and returns the hit count, but when I go to the actual page with the hit counter on it, I receive a parse error. I’ve tried [+id+], and also created a template variable and tried to call it with error incurring each time.
      Any help with this would be appreciated because it would be very useful for me to avoid having to manually insert the id into the field on each and every page, so that it will work for the page itself, and also the ditto call.

      The pagehitcounter call:
      [[ViewCountPageHit? &pre=`` &id=`[*id*]`]]
      <br /><br />The error:<br />
      « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[*id*]' at line 1 »
      SQL: SELECT * FROM modx_page_hit_counter WHERE `page_id` = [*id*]
      <br />
      • Try it uncached, [! ... !]
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 5915
          • 21 Posts
          Beautiful. wink

          I had it in my mind that I previously had issues with it working properly when ditto called it un-cached, but believe I remembered that issue wrong, or I definitely would have tried it prior. I apologize & Thanks.
          • When the parser finds uncached snippet tags it changes them to normal [[ ... ]] tags and continues, so the snippet won’t get processed until the next pass through the parser. The tags inside the snippet tags do get processed, however, so on the next pass the snippet is processed with the value of the TV in place.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
            • Quote from: sarah at Nov 08, 2007, 03:44 AM

              <?php
              /*
               ****************************************
               *
               * Snippet Name: ShowHits
               * Short Desc: Shows hits on pages of the IT Newsletters site
               * Created By: Sarah Vardy
               *
               * Version: 1.0 beta
               * Modified: November 8th, 2007
               *
               * Changelog: 
               *   
               *
               ****************************************
               *
               * Description: 	
               *   Display a list of articles that have had the most hits in descending order
               *   Show the number of hits on a page at the bottom of a page
               *
               ****************************************
               *  
               * Example: [[ShowHits?]]
              */
              
              //connect to table that stores site content
              $table_content = $modx->getFullTableName("site_content");
              $table_hits = $modx->getFullTableName("page_hit_counter");
              
              $fields = 'pagetitle';
              
              $sql= "SELECT {$fields} FROM {$table_content} table_content JOIN {$table_hits} table_hits ON table_hits.page_id = table_content.id  WHERE table_content.donthit = '0' ORDER BY table_hits.page_count DESC";
              
              $output = $modx->db->query($sql);
              
              return $output;
              ?>
              


              Nice work,

              my question is can i HIDE/igonore some of documents in [[ShowHits?]] ?
              For example my INDEX have 1 000 hits but i want just print documents which is in folder Articles? Or Hide 404 document error...

              Like:
              [!Wayfinder?................. &excludeDocs=`217, 218, 219, 215, 94, 165, 216, 94` ...............!]

              !0x
                palma non sine pulvere
              • Add to the WHERE clause something like
                WHERE table_content.donthit = '0' AND table_content.id NOT IN (1,2,3,4,5)

                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                • Quote from: sottwell at Jul 17, 2009, 04:09 PM

                  Add to the WHERE clause something like
                  WHERE table_content.donthit = '0' AND table_content.id NOT IN (1,2,3,4,5)



                  work nice.

                  !0x
                    palma non sine pulvere
                  • is this script work with 1.0.3 huh
                      palma non sine pulvere
                    • Quote from: Kristalin at May 17, 2010, 05:08 PM

                      is this script work with 1.0.3 huh
                      Have you tried it with 1.0.3 and experienced issues? If not, I suspect it will just work.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me