I thought I had this figured out but little did I know...
I need to automatically generate an alias that uses an underscore...
Did a tiny hack and got that. Now however I need to NOT add a suffix to a container....
I thought everything was working because I had already created my containers. Now when I go back to edit them a .html suffix is appended and my navigation breaks. Where is the stripAlias function being called from in the core? Does anyone know what file I’d need to modify in order to do a quick check that if some variable equals container DO NOT add a suffix?
If I specify a suffix in the configuration, it will not be added if I have already specified an alias. However it also seems to NOT append the suffix if I allow modx to create my alias...does that make sense.
For example.
A document with the page title of "File Not Found".
Once saved the alias is created as "file_not_found".
No suffix when specified in config. If I use my hack, I will get my;
"file_not_found.html" just like I want. BUT If I modify a container or create a new one
like:
Pagetitle: Error Pages
alias becomes: error_pages.html
..adds an HTML suffix which doesn’t pass muster.
Anyone have any clue on where to add a tiny bit of logic that will NOT add a suffix to a container?
I twitch because I care....and drink too much coffee.
How about turning the suffix off and just putting .html on the end of the alias for non containers?
You could do that automatically in a plugin listening to OnBeforeDocFormSave if it’s too much trouble to do it manually.
BTW, it’s almost never necessary to hack the core code to do what you want in MODx.
Thanks for the quick reply;
The problem lies when I have the client create new blog entries. I want the .html at the end of each blog entry but without them having to put in an SEO friendly alias. At the same time I don’t want my container aliases to be overwritten when modifying.
I twitch because I care....and drink too much coffee.
Check out ManagerManager!
//Just to hide the field...
Well hiding the field would help, but still not fix the problem of containers. If I go in as an Admin and modify a container then a suffix will be appended to the alias using my hack or if I use the configuration file.
My goal is to add a piece of logic that won’t add a suffix to a container....
I twitch because I care....and drink too much coffee.
Without hacking anything, you can use a plugin that listens for OnBeforeDocFormSave and checks isFolder() (to see if it’s a container). The plugin can do whatever you want with the alias (or any other fields). It will have access to the document after the user clicks on save but before the document is saved to the database.