-
MODX Staff
- 730 Posts
It may have something to do with $modx->aliasListing not getting updated during first document save, but I’d have to look deeper.
The best way to ensure that this gets resolved would be to file a bug report in Jira with this information.
For a quick fix, you would have to get your plugin "do the math" to create the friendly URL you need if the API isn’t working for you.
One question I have, if on the second or subsequent save, and you change the alias, does your plugin report the correct (new) URL or the previous one?
Thank you for your reply, I’ll try to do "the math" myself.
According to your question, I’ve changed several times the alias of document and it changes in return of makeUrl() only after second save. So for example:
1. I create new document without alias - wrong URL without full path as I described in first post.
2. I open and save document again - getting right URL
3. Open, change alias to smth. - getting wrong URL with previous alias (same, as in 2nd point)
4. Open and save - getting right URL with new alias
.. and so on.
-
☆ A M B ☆
- 24,524 Posts
Try a different event; it sounds like the event you’re using is before the cache gets updated, you need one after the cache gets updated since the makeURL function will use the cache, not the database.
OnCacheUpdate should do the job; although you’ll need some extra code in there to make sure it’s being updated because a relevant resource has been created or edited.