We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    I have been helping a community member get his site templated and marked up correctly but have come a cropper.

    I can't find a workaround for Revo when a URL has page anchors as well as URL parameters. The link that is causing the problem is a simple "back to top" page anchor that links to "#top".

    There are multiple solutions for this in Evo, but I haven't been able to find any suitable solution for Revo.

    The default link code is:
    <a id="backtotop" href="#top"><i class="fa fa-chevron-up"></i></a>


    After searching the forums I came up with and tested each of the following with partial success:
    <a id="backtotop" href="[[++site_url]]#top"><i class="fa fa-chevron-up"></i></a>
    <a id="backtotop" href="[[~[[*id]]]]#top"><i class="fa fa-chevron-up"></i></a>
    <a id="backtotop" href="[[++site_url]][[~[[*id]]]]#top"><i class="fa fa-chevron-up"></i></a>


    When a URL has parameters, for example in gallery or advance search, the URL will always take you back to the first page when clicking the backtotop link.

    Example:
    mydomain.co.uk/gallery-1.html
    mydomain.co.uk/gallery-1.html?page=2


    The link generated for both of the above is:
    mydomain.co.uk/gallery-1.html#top


    So if you click totop on "?page=2" you will always be taken back to "gallery-1.html"

    Does anyone have an idea or a workaround to this problem, other than changing the way Revo manages the "link_tag_scheme" - in this case the default "-1" has to be used as the site needs that scheme.

    This question has been answered by Bruno17. See the first response.

    [ed. note: iusemodx last edited this post 10 years, 6 months ago.]
    • discuss.answer
      • 4172
      • 5,888 Posts
      create a snippet 'currentUrl' with

      return $modx->makeUrl($modx->resource->get('id'), '', $modx->request->getParameters(), $scheme);


      and use it like this:

      [[!currentUrl]]#top

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 7527
        • 437 Posts
        Thank you iusemodx and Bruno. Works perfectly!
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 13226
          • 953 Posts
          Thanks Bruno