We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28189
    • 47 Posts
    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.]
      • 3749
      • 24,544 Posts
      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.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28189
        • 47 Posts
        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!
          • 28189
          • 47 Posts
          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
            • 3749
            • 24,544 Posts
            spikku, can you post the plugin code? I'd like to do a blog article on the technique.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28189
              • 47 Posts
              Quote from: BobRay at Jan 21, 2015, 01:33 PM
              spikku, can you post the plugin code? I'd like to do a blog article on the technique.


              Hey Bob,

              I would, but I have a problem with my plugin. It works well for changing content, but it's not running when changing parents from the tree or from the parent dropdown. I'm using OnBeforeDocFormSave. Is there an event that fires when the document changes parents?
                • 28189
                • 47 Posts
                Quote from: BobRay at Jan 21, 2015, 01:33 PM
                spikku, can you post the plugin code? I'd like to do a blog article on the technique.


                Hey Bob,

                I would, but I have a problem with my plugin. It works well for changing content, but it's not running when changing parents from the tree or from the parent dropdown. I'm using OnBeforeDocFormSave. Is there an event that fires when the document changes parents?
                  • 3749
                  • 24,544 Posts
                  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.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 40735
                    • 119 Posts
                    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!
                      • 4172
                      • 5,888 Posts
                      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
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!