So i’m working on a new site with Revo 2.0.6 . I use Friendly Aliases, Friendly Alias Path, allow duplicate aliases. Of course this is working fine for duplicate aliases that belong to different parents, the resulting url is different. (page1/contact , page2/contact, page3/contact etc.)
Now let’s consider this: I set up a resource based news section where people can post news items. All news items are directly below the news parent. Because i have no direct control over user input it can happen that there are multiple news items with the same alias. Because they also share the same parent this results in duplicate url’s.
Saving two resources with same alias and parent works, no warning or anything, and this is probably understandable because of the setting that allows duplicate aliases.
But when i iterate over my news items with getResources the newest duplicate alias item falls back to site_url, the older one keeps the correct url.
These seems like a scenario that more users could encounter.
Would it be possible to somehow force MODx to generate a unique alias for resources that have the same parent?
Another solution could be to pre- or append the resource id when a certain template is used. Something like example.com/news/43/happy-new-year , example.com/news/44/happy-new-year.
Any thoughts?
-
☆ A M B ☆
- 2,475 Posts
This is a somewhat tricky situation: you need to validate user input. If the standard behavior isn’t quite resulting in a viable URL, you may want to consider writing a plugin that manually checks the alias before saving. A simple solution would append the page id or a timestamp or some other unique number to the URL alias. A more complex solution could check whether the alias was unique, and then provide messaging or corrections if not.
-
MODX Staff
- 10,725 Posts
It should not allow saving if the alias already exists in the same folder in the same context. If it does, it is a bug.
One solution is a simple plugin that listens to OnBeforeDocFormSave and appends the current time to the alias before it’s saved.
Hi,
I recently started using modx and have installed 2.1.3 version. I can't seem to locate the "Allow duplicate aliases" anywhere in the system settings. Did this setting go away in this version or am I looking in the wrong place?
Tx, tg
-
MODX Staff
- 10,725 Posts
It's no longer an option. Duplicate aliases are not and never were the problem. Duplicate URI's are however, and since 2.1 the "duplicate checks" are only for the same URI within the same context unless you enable the global_duplicate_uri_check System Setting.
Thanks opengeek for your reply. I currently have left the default setting of No on the global_duplicate_uri_check System Setting, but I still cannot use the same alias for a resource#1 and a symlink that also points to resource#1? I have friendly url turned on where I would like both to have the same alias/URI. I also have use_alias_path set to no because I didn't want to full path for the resource.
What settings need to be changed that will allow duplicate aliases for a record and symlink?
[ed. note: tahoeg last edited this post 14 years, 10 months ago.]
To clarify - I want the same page with the exact same URL to be available through 2 different menus. Is this possible. Currently, I'm not able to make this happen.
I have friendly url turned on where I would like the same resource with different parents to all have the same URL like this: example.com/page1 without showing the full path.
I am new to building websites and all the terminology. What I have found is that modx is a really powerful and flexible CMS and will continue to learn it and use it for all of my sites that I have planned.
It sounds like I'm missing some fundamental understanding of URI's and its importance. Must all resource pages have a unique URI?
Can someone please help me to have a better understanding on this?
I thank you in advance for your time you took in responding to this post and will really appreciate any insight you can provide.