Welcome to the archive of the old FlatPress support forum. Browse more than a decade of FlatPress wisdom! Login is disabled.

The current FlatPress support forum is available here: forum.flatpress.org
Most viewed entries?
  • Is there a  way to show the most viewed entries?

  • Yes, theoretically there is, but it's not implemented.
    You should get all view and then sort them.
  • I'm sorry I don't unterstand what you mean with "all view" ?
  • Hi, I meant the view_counter.txt file, the file of the plugin that adds the viewed .... times.
    You load them and save in an array, for example with the structure entryID => times, then use a function like arsort to sort the array in the reverse order and you will gain the ids using for example a foreach.
    A code could be:
    // Load the views in $count before this
    $i = 0;
    $n = 10; // Entries to show
    foreach($count as $id => $views) {
        // Do something, like echo $id
        if($i < $n)
  • there are some stats in /admin.php?panel=entry&action=stats it's hidden because it's an experimental feature. Views were not implemented IIRC because it is a plugin
  • @pierovdfn I appreciate your help but I'm a total noob. Where do I have to put the code?
  • Well, in this case id dipends on what you want to do...
    A widget? An admin panel?
  • It would be total awesome if it would show up beside the Number of Coments in the Admin Panel in Manage Entrys, but whatever is less work for you to explain :)
  • "there are some stats in /admin.php?panel=entry&action=stats it's hidden because it's an experimental feature. Views were not implemented IIRC because it is a plugin"

    By the way, when I made this in version 1.0, I just got a notice:

    Notice: Undefined index: stats in /var/www/ud01_418/html/pm/remake/admin/main.php on line 192
  • @pierovdfn could you still help me with this problem? Thanks you very much, it would save me a lot of work (going through every entry and writing down the number ov views)
  • LTB, if you migrated to PostViews 1.1 (on that thread you said you’re going to), you get a single array in file postviews.data. Now I wrote the following and put it in PostViews folder (relative path references should be modified if located elsewhere):


  • Thanks LAttilaD, works great! Saves me a lot of Work :) Thank you very much :)
  • You’re welcome, LTB.
  • I found to "dead" entries:

        [entry121021-155852] => 3
        [entry121021-155454] => 1

    There are no entries, no folders in the content folder but there are in the postviews.data

    What part do I have to delete:
  • I believe it’s best to do it by a script:
    file_put_contents('postviews.bak', $text);
    file_put_contents('postviews.data', serialize($data));
    I wrote it just here and didn’t check for any errors, so it creates a backup.
  • Thanks LAttilaD :) You're always a Help, thanks for that :)
  • Would it be difficult to save this list once a day automatically?
  • I haven't really read the above in detail but if you just want to run a particular script once a day then http://cronless.com/ is the free service I use. I've set up and run cronjobs before on my own server, but they're a pain to do - cronless is painless.
  • I would like to bump this thread :) I would love to have a way to see a list sorted by the views. I uninstalled the PostViews1.1 by LAttilaD.
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion