We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4095
    • 372 Posts
    I am grabbing the Page Title and storing it as a session variable, each time I go to a new page it replaces the session, meaning the session holds the current Page Title only.

    Then when I go to a page, say "refereed.html" I want it to output whats in the session variable. Therefore the page "refereed.html" can’t set a session variable or it will destroy the refeering pages varaiable and I won’t be able to get the referring pages Title.

    All is working except how do I prevent "refereed.html" from storing the session variable?

    I’m thinking TV’s which by default allows the variable to be set, and I can diselect it for that one page (using same template though), but the code below doesn’t store the variable, but it does if its used in a Snippet.

    @EVAL $_SESSION['StorePageTitle']= $modx->documentObject['pagetitle'];


    I thought @eval processed the following PHP code?
      [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
      Admin Sandbox Login: sandbox Password: castle
    • Why not simply make this a plugin that immediately sets the current session variable (from previous page) into a placeholder...
      $modx->setPlaceholder('referrer', $_SESSION['referrer']);

      and then set the new one for the current page...
      $_SESSION['referrer']= $modx->getUrl($modx->documentIdentifier);

      Now you have access to the previous one on the new page via the placeholder value
      $modx->getPlaceholder['referrer'];

      or
      [+referrer+]

      , and the new one is ready to process on the next page.

      Just an idea...not sure exactly which event to use, but I believe OnWebPageInit would have the documentIdentifier ready for use and would get processed, even for cached pages (though you might have to use an uncached snippet to get the proper value into/from a cached page).