Introduce yourself here! In order to avoid spam, new users must first comment on the discussion in the 'Introductions' before they become 'full members'
Most viewed entries?
  • Is there a  way to show the most viewed entries?

    NBG
  • 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
    arsort($count);

    $i = 0;
    $n = 10; // Entries to show
    foreach($count as $id => $views) {
    // Do something, like echo $id
    if($i < $n)
    break;
    $i++;
    }
  • 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):

    <?php
    include('../../defaults.php');
    $data=unserialize(file_get_contents('../../'.CONTENT_DIR.'postviews.data'));
    arsort($data);
    echo'<pre>';print_r($data);

  • 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:
    ...2439";i:330;s:18:"entry121021-155454";i:1;s:18:"entry121021-155852";i:3;s:18:"entry12...
  • I believe it’s best to do it by a script:
    $text=file_get_contents('postviews.data'));
    file_put_contents('postviews.bak', $text);
    $data=unserialize($text);
    unset($data['entry121021-155852']);
    unset($data['entry121021-155454']);
    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.
  • 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