We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2623
    • 34 Posts
    Hi all =)

    Is there something like a banner script that would count clicks or page statistics that I could use for sorting documents by "popularity" in a Ditto call?

    Here’s what I need to do:

    My site has a FAQ section that uses separate documents for each Q&A. There’s a simple Ditto call for the FAQ container:
     [[Ditto?  &extenders=`summary`]]


    The challenging part is that I need to display the three or four most popular (or most clicked/ most visited) FAQs on the homepage.

    Initially I thought of counting the clicks from the links in the FAQ container, where I would only display the questions and link to the full Q&A document.

    But I’m guessing another way of doing that would be to count the hits of each FAQ document, using page hits for sorting the Ditto call on the homepage.

    Logic on this is a bit quirky, but hey, it’s not my idea... rolleyes

    My homepage Ditto call
     [[Ditto? &parents=`26` &display=`3` &tpl=`faq_list` &orderBy=`createdon ASC` &extenders=`summary`]]


    I’d really appreciate any help or comment on this =)

    Thanks!
      • 1122
      • 209 Posts
      Please consider the following Kristalin’s question http://modxcms.com/forums/index.php/topic,36351.msg226443.html#msg226443 and Sottwel’s reply to it.
        • 2623
        • 34 Posts
        Yup, that’s it. =)

        I saw that post while searching for Page Hit Counter. I had to change the SQL query, since I need to output only the FAQ items, i.e., a limited set of pages, belonging to one specific folder:

        $sql= "SELECT {$fields} FROM {$table_content} table_content JOIN {$table_hits} table_hits ON table_hits.page_id = table_content.id  WHERE table_content.parent=26 AND table_content.donthit = '0' ORDER BY table_hits.page_count DESC LIMIT 3";
        $results= $modx->db->query($sql);



        Thanks Alik!