We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25067
    • 5 Posts
    I’m using Evo 1.0.2 with Ditto 2.1 and am trying to figure out a way to redirect a user who clicks on a friendly URL search result page to that same page’s parent which contains a ditto call to display all of its children pages. The trick is I want the ditto call to "jump" to the ditto result for the corresponding page the user clicked on and not just the first page in group of results.

    I have searched all over and found some re-directing snippets and ditto extenders but they need to have the query parameters in the original URL and since this is from a direct link to a page there are no query parameters to pass on to Ditto. So, I am stumped...

    For example, lets say there are 10 pages under the parent page (container) and the user clicks on page3.html from the search result. What I’d like to do is have page3.html redirect the user to parentpage.html?start=2

    Is there some way to get Ditto to jump to the page it was called from so, if I were to put a ditto call on the template for page3.html with
    [!Ditto? &parents=`[*parent*]` &tpl=`myCode` &orderBy=`pagetitle ASC` &paginate=`1` &display=`1`!]

    that it would still find all 10 pages under the parent doc and just jump to page 3 of 10 with pagination showing for all 10 pages? i tried passing the &start parameter though a TV but that discards all the pages you skip so that won’t work either.

    Is there some other way to do this that is better?

    Any help with this would be greatly appreciated!

    Thanks,

    -Paul


      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The only thing I can think of is to have a snippet that checks the referrer, and if the referrer is not the container page, then redirect to the container page. Put the snippet in the template for those documents. If you use the same template for the container and its children, you would need to add a line of code to skip the check if the document being parsed is the container document. This wouldn’t help if you did the search from the container page (presuming you’re using AjaxSearch).

      Or, if you’re using the Highlight Search Terms plugin, your snippet could look for its query string and redirect if it exists.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 25067
        • 5 Posts
        Bummer...don’t have the PHP skills to create a snippet.

        However; I was able to hack the existing phiRedirect snippet, http://modxcms.com/extras/package/338 and get the parameter
        ?start=[*tvName*]
        passed to the container URL.

        "tvName" is a template variable containing the page number for Ditto to jump to after some Phx math. Not as automatic as I’d like but it’ll work.

        Thanks again for the response, it got me going in the right direction.

        -Paul