-
☆ A M B ☆
- 113 Posts
We are running a news web site in MODx Revo and Google News inclusion requests a unique five digit numerical code in each article. I can't expect the site editors to insert the code into the alias every time, I can barely get them to add tags, so I would like to do it automatically. I also do not want it to be hard coded so it would be wiped out by future updates. Does friendly URL's or maybe form customization provide a mechanism for this? I searched the settings and didn't see any method of changing the alias auto-population method.
Thank you, any ideas are much appreciated!
Just a Thought:
This may need to be done in a Plugin. I'm just thinking through it.
If you have a container called news with id of 123 that holds all your news articles it would be a little easier to differentiate news articles from other pages.
If I were trying this I would then create a Plugin that fired on something like OnDocFormSave but maybe OnBeforeDocFormSave . If you put all your news articles in a container called News, you would be able to query the Resource being saved to make sure it's in the news container by looking at the Parent IDs. That way you make sure to only modify news articles. If they aren't in a container news maybe you could make sure every news article has a specific TV.
Then you could modify the alias when the Resource is saved. to make sure it contains a five digit number. You would have to query the current alias to make sure you don't keep adding it on so the alias doesn't get longer and longer.
For the five digit number, I would use the Resource's ID, but modify it a little (but that's because I'm mental about hackers). I would do something like take the ID and multiply it by some random number or reverse it, and then add some leading zeros to make sure it's five digits. Does the number have to be exactly five digits? Because if so, you only have 99,999 news articles you can write.
When you program the plugin, make sure you take into account that sometimes it will be a new document being saved and sometimes it will be an existing document.
(It will be something like- modSystemEvent::MODE_NEW or modSystemEvent::MODE_UPD )
one code appended to all URLs ?
sort of like mynews.com/sports/his-story-12345.html
where all pages of the site would end with 12345.html
If so in the manager go to System/Content Types and edit the HTML file extension (in my example it would be 12345.html changed from .html)