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

    This is my first post so please go easy on me if i’m being a noob...

    I’m putting together my first site(s) with MODx (I chose it because I have the skills in XHTML/CSS and a little JavaScript, and MODx is far and away the coolest solution for a nicely designed site without naff templates and my client loves it too! - but my knowledge of PHP in particular is close to _, so can anyone please offer a solution to my problem - it should be a simple one I think.

    I have a ’back to top’ button for long pages, currently stored as a chunk so I can just add it anywhere it is needed, but the anchor ’#top’ always redirects me to that anchor on the index page and not the current page. I figure I just need to get the current document id and inject it somewhere, but I just can’t seem to figure out the right combo and placement. I’m using friendly URLs if that has any bearing on it. Thanks in advance.
      • 22303 MODX Staff
      • 10,725 Posts
      You’ll need to reference the document link, i.e. [~34~]#, or [~[*id*]~]# for current page. You can also use a plugin like AnchorsAway, which does the same thing automatically, and can easily be customized as needed.

      One gotcha, be aware that with the AnchorsAway and the [~[*id*]~] method, the links will not reference the proper page if they appear in content summarized by Ditto or a similar method, since the current id would not be for the original page it is intended to be rendered on.
        • 2396
        • 101 Posts
        Ouch, that was just too easy - I was searching for all sorts of crazy document ID related stuff and the fix was just a couple of keystrokes away - still getting used to where to look on the MODx site for stuff too... embarrassed A case of couldn’t see the woods for the trees.

        Thanks so much OG, it works perfectly now.