So far we had id and alias to identify a resource. Both alias and id [[~123]] and [[~alias]] could be used in link tags to get the URL of a resource.
Now Revo 2.1 supports this new URI setting which can be frozen. The new setting is welcomed as it offers more control about the location of a resource which before was tricky (but possible) to do.
Situation is we have two very similar things now: alias and URI.
With the new concept I thought the alias would now be just a textual reference (opposed to the id being a numeric reference) to a resource, and what becomes the URI is defined by the URI setting. In most cases this may be the alias but not always.
If that is the correct understanding of the "new" meaning of alias, [[~alias]] should still work, but is doesn’t once Freeze URI is enabled and the URI is different to the alias. The frozen URI is shown in the aliasMap array instead and the resource cannot be referenced any more by the alias.
Is this intended?
Using [[~123]] has always been the recommend method because it will still work even if the pagetitle, alias, FURL setting, or now URI is changed.
Hi Bob,
thank for trying to help out here. This is appreciated. I know what the recommended way is, but MODx beauty is that you can do things like you want and are not restricted by a particular usage paradigm. Hardcoded resource IDs are good for a lot of things and may be recommended but are not the ideal for every use case.
The reason why [[~alias]] is there, is that people can use it I suppose.
I like [[~alias]] and use it sometimes because I can change the resource they are pointing to very easy. And most importantly an alias link can be used in a chunk which can be reused in multiple contexts. For example a link to [[~info]] points nicely to resource 102 in context A and to id 276 in context B. Using alias links abstract chunks from your site structure. It also makes it easy to copy chunks to a new site design and re-use them.
Now the question I have really is: Is the appearance of the URI instead of the alias in the aliasMap a bug or oversight introduced in 2.1 or can we write off aliases in the future?
Using [[~alias]] was never an intended feature, in my knowledge.
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
In most cases, it means a lot of extra typing, rewriting code every time you change an alias, and it keeps you from creating links by dragging and dropping them from the resource tree. But I see your point about the cross-context links.
-
MODX Staff
- 10,725 Posts
You should now be able to use the uri value in link tags, e.g. [[~[[*uri]]]], but this obviously has some major limitations and is not recommended. Using alias will not work, as that will not be found in most cases, since the aliasMap is actually a map of the uri’s. The alias field could be the same for many Resources in a site.
Hi OpenGeek,
Thank you for stepping in here. Now that explains it. Appears that I used by "accident" an undocumented but useful feature.
To sum this up:
- The former undocumented [[~alias]] notation is now a [[~uri]] notation.
- This is an undocumented/hidden feature and not the preferred usage to link to resources.
This alias/uri relationship now raises some questions which I hope you may shed some light on:
What purpose has the alias once frozen URI is enabled? Has alias not become redundant? What is on the roadmap for alias and URI in the near future?
PS: Before the arrival of the URI feature (pre 2.1) I configure MODx to allow / in the alias so I could configure the URI paths independent of the document tree which basically emulated the frozen URI feature.