Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Which js file contains about Views count?

I'd like to see how the view count works on vanilla 2.1 hoping that this will be taking care of by js. so, where is that js file? where do i find it?

Thanks,

Comments

  • 422422 Developer MVP

    wouldnt views count be handled by the database. hmmmmm

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited March 2013

    maybe this will help you.

    the view count is computed from $Discussion->CountUnreadComments in helper_functions.php in vanilla/views/discussions

    and the css classes that affect display are HasNew JustNew NewCommentCount

    not sure what you mean by .js

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks,

    I thought the view count handled by javascript. and was looking a javascript file for that. Anyway, what i'm trying to accomplish is to modify/write a small plugin to display a false view count. The current viewcount+10 or some for some reason.

    Thanks,

  • Actually I misinterpreted your question I thought you meant unread comments.

    maybe this will give you some insight.

    http://vanillaforums.org/discussion/comment/169174/#Comment_169174

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Ok under

    applications/vanilla/views/discussions

    i found the file table.php

    on line 105 there is a view echo display

    echo BigPlural($Discussion->CountViews + 100, '%s view');

    So, i added the +100 and it works fine. But i'm not sure that's the correct way. Can anyone advice please....

    Thanks,

  • hgtonighthgtonight ∞ · New Moderator

    @Jone

    This seems like it will fix your issue for this view. Remember to put any modifications in an addon, in this case a theme. This will prevent upgrading pains when some of your hacks no longer work or will be overwritten etc. You can read more about views on the wiki.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • JoneJone New
    edited March 2013

    @hgtonight Thanks, I'm learning PHP and then make a plugin on vanilla. yeah, it's not perfect but that will be a temporary solution. I'd like to add a time interval, like: for new post add 50 after 10 min, and for other if the topic posted <=24 hour add 50 every hour... something like that.

  • The very bad thing for this solution is when a new topic posted less than a min it says the view 102 views. I should learn PHP very fast... lol

  • hgtonighthgtonight ∞ · New Moderator

    @Jone I would look into using the cron jobs plugin as hooks in your plugin. Otherwise you are stuck executing code whenever a page loads and have to do some fancy calculating for this inflating of views to not be noticeable.

    Good luck!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @Jone said:
    hgtonight Thanks, I'm learning PHP and then make a plugin on vanilla. yeah, it's not perfect but that will be a temporary solution. I'd like to add a time interval, like: for new post add 50 after 10 min, and for other if the topic posted <=24 hour add 50 every hour... something like that.

    why the deception?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • GaryFunkGaryFunk Senior Application Developer ✭✭

    @peregrine said:

    I am wondering the same thing. Soon it will come back to hurt him.

  • JoneJone New
    edited March 2013

    Actually, I'd like to using it like a motivational tool for some users. The forum is new and some users write how to's and life experience topics. not exactly question or discussion topics. So, i don't want them feel nobody reads their posts, i know the forum will be famous soon. but, till then i don't want to loose the current users coz of nobody reads their post. is that a bad idea to hold users? i'm i doing wrong? please you can advice me.

    Thanks,

  • hgtonighthgtonight ∞ · New Moderator

    I wouldn't suggest inflating view count. Seems to me when your users find out they will be none too happy (and someone will find out).

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • 422422 Developer MVP

    Rather than use an even number use one ending in 9 that way looks more natural because ... Say you incremented by 9 each time, the view count looks more natural ...

    9 18 27 36 45 54 63 72 81 90 etc

    There was an error rendering this rich post.

  • 422422 Developer MVP

    or use php rand to add an incremental amount each time between say 29 and 45

    There was an error rendering this rich post.

Sign In or Register to comment.