We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12983
    • 108 Posts
    If I have friendly urls deactivated, when I want to link a page is there a way to use the alias instead of the id? That is, something like:
    <a href="[~the_page_alias~]">page</a>
    

    instead of
    <a href="[~71~]">page</a>
    

    ?
      • 25547
      • 61 Posts
      dont think there is a simple way
        • 12983
        • 108 Posts
        Thanks, good to know; another reason to activate friendly urls.
          • 25663 MODX Staff
          • 12,272 Posts
          There is a snippet for calling a page by an alias in the repository actually for this. I think OpenGeek himself created it. Check out the new as of yesterday Navigation & Tagging/Taxonomy forum topic (more of those to come).
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 36592
            • 970 Posts
              • 25969
              • 118 Posts
              Yep seemed to work quite well. I was wondering how this would work with duplicate alias’ allowed and it prob does the logical thing, the first document it comes across (based on Doc ID) with the right alias gets linked to.

              Other’s in the old thread on AliasLinks seemed to have trouble with this and PHx together.
                • 12983
                • 108 Posts
                Nice. Still there is a problem: when snippets/etc. use a parameter for document nodes, they use the id (think Ditto as an example, the parent parameter). And this cannot be replaced in any way by the document alias, am I right?

                This is somehow a problem for us, the best would be to have independence from id numbers, and relying only on (unique) aliases: this is true for several reasons I’ll not explain here.

                Can someone suggest some way to accomplish this?
                Maybe a universal snippet for calling snippets, passing the given parameters as the same parameters with the same name and value, and replacing parameter "alias:aliasname" with the id number corresponding to the specified unique alias?
                i.e., something like:
                [!snippetcall? &name=`Ditto` &parents=`[+alias:newsfolder+]` &start=`0` &sortBy=`pub_date` &paginate=`0`!]
                


                Or could this slow down things too much to be worth of?