WordPress.org

Ready to get started?Download WordPress

Forums

Ajaxize
[resolved] Ajaxize for WP Post Views ? (20 posts)

  1. evo252
    Member
    Posted 2 years ago #

    Hello,

    Thanks for this great tool ! I would like to know how to ajaxize WP Post Views plugin in order to make it work with W3 Total Cache and Varnish Cache. In fact, WP Post Views doesn't increment well counters of posts because of caching solutions we have on our blog.

    I tried to ajaxize 'the_views' function, but the counter displays "0 views" rather than the real amout of views.

    Thanks in advance ;)

    http://wordpress.org/extend/plugins/ajaxize/

  2. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Hi evo252,

    I'm not entirely sure to be honest. Had a quick-check and got the same behaviour as you. I'm not familiar with this particular plugin, but it might check the views based on information in the page/post itself, and therefore, when accessed via the ajax call, it doesn't get the contextual information it needs...

    Don't think there's much I can do about that, but best thing is to contact the plugin author.

    I did however notice on the plugin info that it claims to work with caching solutions.

    Yoav

  3. evo252
    Member
    Posted 2 years ago #

    Hello Yoav,

    Thank you very much for your help. Unfortunately, the author of WP Post Views is not able to provide support since 1 year, so I don't find any solutions for this specific problem, and no alternative for counting views on articles.

    WP Post Views runs fine with WP Super Cache but unfortunately not with W3 Total Cache (and less for server caching solutions like varnish): I noticed a big decrease of number of readings since cache has been installed on my server, so the only solution would be an ajax counting views.

  4. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

  5. evo252
    Member
    Posted 2 years ago #

    Yep, but it shows "Please wait" indefinitly :(

  6. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    This is probably not the right forum, since I'm trying to solve a bug in another plugin, but I've had a quick look and if you want a real quick-n-dirty fix for ajax-the-views (not for my plugin though), then try adding this javascript to your footer.php (right after wp_footer)

    like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  7. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

  8. evo252
    Member
    Posted 2 years ago #

    Hey Yoav,

    Hope you're fine, and thousand and thousand thanks for your help.

    I didn't understand exactly what is the changes provoqued by the code you sent me, is it not the same that ajax_the_views launches at the footer page ? Anyway, I implemented it into my code and it didn't change anything: "Please wait" continues to show rather than the views.

    Let me know !

    Thanks again

  9. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    there's a slight change to the code that generates the javascript (particularly the url where the javascript gets its data from). Testing it quickly on my wordpress, I did get back '2 views' instead of 'Please wait' after I placed it in the theme's footer.php

    As I said it's a very 'quick-n-dirty' fix, so perhaps not what you should be searching for. I suggest posting on other forums or searching for different post-views plugins if you can't get this to work.

  10. evo252
    Member
    Posted 2 years ago #

    Hello Yoav ! It works like a charm ! Awesome, the plugin counts now the views in real time :) I don't know if you can, but I think you should update the plugin Ajax_the_views on the wordpress plugins library.

    Strange fact: your hack didn't run well immediately on my blog (but worked on another test blog), but after putting your code on the header and not footer, it has worked. Note that I deleted the precedent code on the ajax_the_views PHP file, hope i made things correctly.

    Thnk you so much !!!!!

  11. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Glad it helped evo252. It's not that simple to update somebody else's plugin code. Usually you'd have to ask them for permission, and some times make another plugin copy... Not exactly what I had in mind when I created Ajaxize. I'm not even sure my fix is the right one. As I said, it was very quick and perhaps not the most elegant way to solve this problem.

    The best thing you can do is post a message on the ajax_the_views forum and ask about it. You can probably also point to this thread / code in pastebin. I know I can do it too, but since I'm not actually using this plugin, I feel it might be inappropriate in this case.

  12. evo252
    Member
    Posted 2 years ago #

    Hello,

    Ok, I understand, it's as u like. I think however that the fix is correct, because the tool is working very well ;)

    Thank u so much...

  13. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    No problem. If you want to help others, I really suggest you post something on the ajax_the_views plugin forum. It's up to you of course.

  14. evo252
    Member
    Posted 2 years ago #

    Hello Yoav,

    I wanted to say you thanks again, because I'm so indebted to you for the time you gave me to fix the bug of this plugin !

    I've posted a message to inform those who could have the same problem as me on the plugin forum !

    Thank u so much...!

  15. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Evo252,

    Thanks for doing it.

    BTW, Ajaxize 1.1 now supports context information, and should in theory also work with functions like the_views.

    I guess you already have a working solution for WP Post Views, but you might want to do it through ajaxize. If it works it might be slightly more elegant, and no need to tweak footer/header php files.

    Yoav

  16. Moogle Stiltzkin
    Member
    Posted 2 years ago #

    I'm not really sure what ajaxize is suppose to do.

    Is it about making the site more w3c standard compliant by making other plugin authors coding hook to output only 1 code that is required rather than many duplicates ?

    Sorry, bit of a nub here :X

  17. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Moogle,

    It does neither of those things actually.

    Ajaxize helps users take an existing plugin, php function, and turn it into an ajax call. This helps overcome issues with caching solutions and can be helpful in a number of other cases.

    More information about the plugin is available on the faq section.

  18. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Another note about WP Post Views. I have tested it on a clean wordpress installation, and ajaxize works well with WP Post Views. No need to install http://scratch99.com/wordpress-plugin-ajax-the-views/ or tweak any javascript.

    Ajaxize and WP Post Views should work 'out of the box' :)

  19. Stephen Cronin
    Member
    Posted 2 years ago #

    Hi Guys,

    I missed all this, but I'll have a look into whether I can include Yoav's changes into ajax_the_views. The plugin works for me on my site as is and I haven't been able to work out why it's happening for other people.

    A big thanks to you Yoav.

    Cheers,
    Stephen

  20. yoav.aner
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Stephen,

    Thanks for the feedback. Would be great if the ajaxize code can be used elsewhere or extended/improved.

    I didn't try to 'compete' with any other plugin, but rather to find a generic way to 'ajaxize' plugins and functions. I only heard about ajax_the_views after I released ajaxize and evo252 posted about it. Anyway, open source is great for these kind of things so I'm looking forward to more feedback and ideas.

    Yoav

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags