Hello,
We want to use use_alias_path, but not for all pages. Currently, the document templates would work as a differentiating factor.
Here's an example of what we're looking for:
Root -> Guides -> Karate -> Chop Technique
/guides/karate/chop-technique.html
and
Root -> Products -> Karate -> Chopping Glove
/KCG01.html
I'd like this to happen without a redirect. The approach I was taking, with use_alias_path set to Yes, was creating a plugin to run OnPageNotFound. I've extracted the alias and can pull the resource object, but at that point how could I render that document with a 200 status code?
Or, am I doing it wrong? Any help or guidance would be appreciated. Thank you!
-Bo
[ed. note: spikku last edited this post 11 years, 8 months ago.]
On the "Settings" tab of each resource, there's a "Freeze URI" checkbox. If you check it, a new input field will appear where you can set the URL for that resource. You can set use_alias_path either way and set the URLs of just the resources that don't appear the way you want them to.
You could also do it with a plugin, but you're going to have to identify all resources it should affect and re-write it every time you add a new resource. I think the first method would be easier and more reliable unless there's some set of rules you could use to identify which resources you want to change the URL for.
Thank you, Bob! That's definitely helpful. It's funny, I've seen that checkbox a million times probably, and didn't even think about it in this case. I've never needed to do goofy things with the URLs.
This also gives me an idea for a new approach. The vast majority of pages need the path off. So, I'll try leaving use_alias_path off, and set the Freeze URI for the others based on their parents. I'll test this tomorrow. Thanks again for the guidance!
Just thought I should post a follow-up. The Freeze URI option works well and has been automated with a plugin (OnDocFormSave) by building the Freeze URI automatically using the parent tree aliases.
Thanks again!
-Bo
spikku, can you post the plugin code? I'd like to do a blog article on the technique.
OnBeforeDocFormSave fires only when you save a resource from the document form, so it won't work if you drag something in the tree. I'm afraid I don't know of an event that would fire when you move things in the tree. Though your plugin should work when you change the parent on the Create/Edit Resource panel and then save the resource. If not, you might try OnDocFormSave.
I have a similar but different case. I have a single container resource with the alias "/news" and I want everything below it to appear without the alias path. E.g., /news has a child that is a container called "archive" for organizational purposes. I want the resources it contains to all be located at /news rather than /news/archive. I tried freezing the URI and using /news but it won't allow duplicates apparently. Is there another way to skin this cat?
Thanks!
you need to freeze the urls of the news-pages itself, not the one of the container.
This could be done with a plugin for OnDocFormSave automatically.
If you want it also checking, when moving a resource in the tree by dragging, there is the event OnResourceSort