Is there any way to add recent visits of spaces/pages in scroll viewport theme

Comments

5 comments

  • Avatar
    Nils Bier

    Hi Sanker,

    Thanks for reaching out.

    Could you share some further details what exactly you're trying to achieve? Do you want to have a counter displaying the number of visitors of a certain page?

    Best,
    Nils

  • Avatar
    Shanker Perumalla

    Hi Nils,

    I want to show the list of recent pages that user visited, so that user doesn't have to search for a specific page every time.

    I think it could save some time for the user. This feature is available in confluence.

    Just wondering is there any code snippet available in Viewport to do the same?

     

    Thanks,

    Shanker.

  • Avatar
    Nils Bier

    Hi Sanker,

    Thanks for the further details.

    The only place I know of where information about recently viewed pages is stored, is in the user dialog "recently viewed" (see screenshot).
    You can build that into your theme by using the following REST resource: /rest/recentlyviewed/1.0/recent?_=1527154073542 (I assume that the query parameter is for cache-busting).

    I hope this information helps to get you started.

    Cheers,
    Nils

     

  • Avatar
    Shanker Perumalla

    Hi Nils,

     

    Thanks for the information.

    I was able to retrieve the recent visits using the REST URL you have suggested.

    But if I visit the confluence page only, it will add that to the recent visit list.

    We restrict the access to confluence view and redirect user to viewport view.

    When user visit the page in viewport view, it doesn't reflect in recent visit result.

     

    Thanks,

    Shanker.

     

  • Avatar
    Steffen Burzlaff

    Hi Shanker,

     

    thanks for reaching out to us.

    To update pages in the recently viewed list out of a Scroll Viewport, you need to pretend a Confluence page view for Confluence.

    So to do this, you just need to save the current Confluence URL and make an AJAX post with that URL.

    This is how I implement that:

     

    In your HTML-Head include:

    <meta name="viewUrl" content="$page.viewUrl">

     

    In your javascript file, just do the Ajax call after loading the DOM:

    $.post($('meta[name="viewUrl"]').attr("content"));

     

    That's all. This will Confluence know, that the page has been viewed and so the 'recently viewed' list should be updated.

    Let me know if that worked out for you!

    Best,

    Steffen

Please sign in to leave a comment.

Powered by Zendesk