We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21978
    • 59 Posts
    Hi,

    I have a problem - probably with Ditto. I have 2 pages which are just grouping specific language versions of the website (let’s call the A and B). The only thing that happens on those two pagea is:
    - call to a snippet which sets a specific value to my SESSION variable
    - execution of FirstChildRedirect.

    I know that using Session variables is not the best solution, but in this very example I just need to have it.

    Coming closer to the problem.
    Let’s say I navigate to one of those two pages - page A, the session variable is set and I am being redirected to another page. This "another" page has a Ditto call inside which gets documents by tags. As I understand - getting documents by tags requires "scanning" all pages if they have this tag set.
    The problem I am experiencing is that during this scan, Ditto probably executes the page B which causes SESSION variable to be set to a different value than I am expecting.

    Could You please explain me how Ditto works in this area? Does it really execute my page B? What should I do?

    Thx
    Greg
      • 10449
      • 956 Posts
      I guess it’s rather the use of FirstChildRedirect that somehow conflicts with your session vars. Ditto doesn’t "execute" every page that fits into the parents parameter. It collects the pages internally, pulls all needed contents from the DB (according to the tpl chunk you set), and prepares the rendering of those template chunks. All that’s executed is the Ditto call on which page you’re on.

      However, if you have a snippet inside [*content*] that manipulates session vars, and you’re using [+content+] inside your Ditto-template chunk, then yes, this snippet gets executed too.

      For debugging, try using the &debug parameter in your Ditto calls. Also, instead of just setting a session var, use print_r or simple echo() to verify your vars on every page.
      If this is a live site, wrap the output inside HTML comments:
      <!--
      my session var x = [!snippetName!]
      -->