We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32098
    • 31 Posts
    How do you do links within the page in Modx Revolution?

    Have look for an answer on the forum for this problem but can find nothing. A simple problem (perhaps bordering on the dumb), but I can’t work out the solution.

    This is what I am trying to translate into Modx Revolution syntax:

    <p><a href="#here">Clickable anchor text</a>.</p>
    ...
    <a name="here"></a>
    <p>Destination text on another part of the same page.</p>


    The following does not work:

    <a href="[[~[[*id#here]]]]">


    The output to the browser is simply:

    <a name="here">


    And the result of clicking the link is that the site flips back to the home page (friendly URLs are operative in this instance, if that makes any difference).

    So what is the proper Modx Revolution syntax for this kind of intra-page link?

      • 26016
      • 561 Posts
      Hi,
      The simple answer is "anchor". I am pleased to find that this is something that Revo seems to do better than Evo. I just worked it out, and you can try it. My method is using the popular Tiny editor that is nearly standard equipment in MODx.

      Fill your page with text.
      Then highlight a word or phrase in the text.
      Then look at the editor toolbar, and click the thing that looks like an anchor (it’s next to the "Link" and "Unlink" items), enter a name for it, and click Insert.
      Then find (or write) the word (or phrase) on your page that you want to link to the anchor, and highlight it.
      Click the "Insert/Edit Link" thing on the toolbar. Under "anchors" you should see your brand new anchor listed. Click that. Save, and it should work.

      I am very pleased to see that this worked even when using BASE HREF in the template, which was quite problematic in Evo.

      Dave
      PS: I played with trying to get this to work using tag variables, and I didn’t get that to work.
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 33983 ☆ A M B ☆
        • 181 Posts
        In the docs: http://rtfm.modx.com/display/revolution20/Named+Anchor.

        On a similar note, does any know if there is an option to use the full URL instead of page name so I don’t have to use the <base> element with the friendly URLs?
          • 33337
          • 3,975 Posts
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 3749
            • 24,544 Posts
            Try this:

            <a href="[[~[[*id]]]]#here">jump</a>


              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 26016
              • 561 Posts
              Quote from: BobRay at Jan 24, 2011, 10:26 PM

              Try this:

              <a href="[[~[[*id]]]]#here">jump</a>



              All right, Bob!
              You know what, in MODx 3, there will be 32 brackets and 7 tildes around every command, you’ll see!

              Cheers, Dave
                MODx and Wordpress development
                Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                • 3749
                • 24,544 Posts
                Honest, it looks normal once you get used to it. The Evo tags look funny to me now. wink
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 32098
                  • 31 Posts
                  Sorry for taking nearly 8 months to say a big "Thank you" to Bob and Samba. Yes, those solutions worked.

                  As in philosophy, the trick is not so much to know the answers as to know what the right question to ask is. Now I realise the issue here is Named Anchors, and knowing that it ain’t hard to find the relevant page in the documentation, which does explain the issue very clearly:

                  http://rtfm.modx.com/display/revolution20/Named+Anchor