Results 1 to 5 of 5

Thread: how to save the last page browsed ?

  1. #1
    New user
    Join Date
    02-24-12.
    Posts
    19

    Default how to save the last page browsed ?

    Hello,

    I am developping a module to save the last item a client consulted on my shop, created with isotope, to display a list of last items in case the client want to go back on it easily.

    My problem is I have no idea how to trigger this 'saving event' when the client click on the link of the product, to see its details.

    I'd like to to that so I can save the page url, ie the product id, in my table with the user's session.

    I don't know if I should keep creating a separate module or extend isotope, so if you have any idea it would be very welcome.

    Thank you.

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: how to save the last page browsed ?

    Hmm. I wonder if you could try the "getPageIDFromUrl" hook...
    http://www.contao.org/en/hooks.html#getPageIdFromUrl

    So that would fire right at the beginning when a page is attempting to load.

    You could perhaps check that the page being loaded is a product detail page, and if it is, save the URL passed in (and you should be able to find the product ID from that URL too), and then you can also get and save the user session.

    There might also be an Isotope-specific hook that can help, but I'm not sure if those are document yet, so they'd be harder to find. If you did a text search of the Isotope folder for something like
    Code:
    if (isset($GLOBALS['TL_HOOKS']['
    That would help find most/all of them (that block starts just about every hook call).
    Brian

  3. #3
    New user
    Join Date
    02-24-12.
    Posts
    19

    Default Re: how to save the last page browsed ?

    Thank you for your answer, the "getPageIDFromUrl" hook should help a lot.

    I managed to do it a few minutes ago by calling a homemade method directly on the template iso_reader_default.html5 which is the one used by isotope to display the products details. This way it is only launched when a client go see the details of the product and it is exactly what I want. The method then update a table with a field 'session' and another 'lasturl'.

    This is working but I m not sure it s the right way to do it so I ll try with getPageIDFromUrl.

    If someone is interested I can put details of what my code is doing. If I manage to do it in a more clean way using this, I ll tell you too.

    Again thank you very much for your time.

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: how to save the last page browsed ?

    Honestly, if I were doing it, I would do it the way you did (putting it in the template). Especially if it's a one-off kind of thing its the easiest and most straightforward, and you can get all the info you need (incuding product ID) directly from the template.

    I only mentioned the hook because if you're developing a reusable module, it is in theory cleaner and completely separate from your templates.
    Brian

  5. #5
    New user
    Join Date
    02-24-12.
    Posts
    19

    Default Re: how to save the last page browsed ?

    ok, I keep it that way then, but I may have to do a reusable module with more options later, like the number of products to keep in memory, things like that...so I will look into the hook when I do that.

    Thanks !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •