Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David McGawn 37 posts 150 karma points
    Aug 09, 2016 @ 09:07
    David McGawn
    0

    No Data :-(

    Morning, i have installed your package and added the DataType etc.. but the counter is not working and the database table has no entries

    Thanks

  • Cimplex 113 posts 576 karma points
    Aug 09, 2016 @ 09:09
    Cimplex
    0

    Hi David, Did you place the code given on the project page in your view?

    https://our.umbraco.org/projects/backoffice-extensions/uincrement/

    // Herman

  • David McGawn 37 posts 150 karma points
    Aug 09, 2016 @ 09:16
    David McGawn
    0

    Thanks for the quick reply, yeah i have added: but it is

    @using uIncrement.Core.Services   
    CounterService.Increment(Model.Content.Id);
    CounterService.IncrementSession(Model.Content.Id);
    @CounterService.GetValue(Model.Content.Id, 7)
    @CounterService.GetValueBetween(Model.Content.Id,
    DateTime.Parse("2016-06-01"), DateTime.Parse("2018-06-30"))
    

    but it is just giving me this

    Thanks

    David

  • Cimplex 113 posts 576 karma points
    Aug 09, 2016 @ 09:24
    Cimplex
    100

    Hi David, are you able to paste all code in your view?

    This code should work:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using uIncrement.Core.Services
    
    @{
        CounterService.Increment(Model.Content.Id);
    }
    
    @CounterService.GetValue(Model.Content.Id, 7)
    

    That code should output a number that increments each time you reload the browser.

    Are you able to find a database table named UIncrement_Counter in the database? Can you check your log to see if it there are any errors?

    // Herman

  • David McGawn 37 posts 150 karma points
    Aug 09, 2016 @ 09:29
    David McGawn
    1

    What you have just sent works.

    but what is the need for this one

    CounterService.IncrementSession(Model.Content.Id);
    

    Is this just to do sessions instead of page views?

    Thanks

  • Cimplex 113 posts 576 karma points
    Aug 09, 2016 @ 09:36
    Cimplex
    0

    Hi David,

    Sweet! The IncrementSession creates a session for the user to prevent the counter to increment every time the user navigates back to the same node, or reloads the page.

    You can debug this by clearing your cookies and the counter should increment one time per cache cleaning, or if you have two computers the counter should increment one time per computer.

    // Herman

  • David McGawn 37 posts 150 karma points
    Aug 09, 2016 @ 09:38
    David McGawn
    1

    Thanks That was brilliant

  • David McGawn 37 posts 150 karma points
    Aug 09, 2016 @ 09:39
    David McGawn
    0

    Sorry one last question is there a quick way to block internal work traffic from this counter?

  • Cimplex 113 posts 576 karma points
    Aug 09, 2016 @ 09:43
    Cimplex
    0

    Sure!

    You could probably do something like this:

    if (HttpContext.Current.Request.Url.Host.ToLower() != "localhost")
    {
        CounterService.IncrementSession(Model.Content.Id);
    }
    

    or replace localhost with you dev domain.

    // Herman

Please Sign in or register to post replies

Write your reply to:

Draft