We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3177
    • 137 Posts
    Hello MODX-world,

    I have a question on the Friendly Alias Path.
    The case is that we have switched off the friendly alias path in the
    friendly url section because we do not want to have the paths
    included in our urls. Reason is that we structure our document-tree
    in such a way that we don’t want this to show to the world.

    However, for some urls we DO want alias paths. These are the
    Google optimized urls in the site.
    We have experimented with adding a slash in the Document Alias,
    but this does not work.
    Another option is to put the urls with the slash (=path) in them
    hardcoded in the .htaccess file. But we do not want to change the
    standard .htaccess file delivered with MODX.

    What would be ideal is either one of two options:
    1) MODX allows slashes in the Document Alias
    2) It is possible to specify per document if it should include
    the path in the url-friendly url.

    Are there any other options?
    Are there already any hacks on the MODX core to achieve this?
    Does anybody else have the same need?
    Do the core-developers see this as a nice feature for the next release?

    Any help is appreciated.

    Regards,

    Bert Catsburg
      • 4310
      • 2,310 Posts
      Strange coincidence.
      I’m just looking at taking on an existing site that has a similar requirement due to multilingual folders.
      It would be nice to able to have the second level and lower docs to have the alias path type url’s.
        • 3177
        • 137 Posts
        Hello Bunk,

        You want something slightly different I guess.
        You want to define the alias path but not take the whole path
        and start at a lower level. So, you probably have the language
        codes at the highest level but do not want them to show in
        the friendly url.

        To combine the solution with my request makes that the
        best solution is that the "Document Alias" field in the document
        accepts (and don’t throw away) slashes in the urls.
        That way everybody can do what they want.

        A restriction might be that slashes are taken away if
        Alias Path is set to Yes.
        If Alias Path is set to No, then slashes in the Document Alias
        are not taken out.

        (Somebody more familiar with the core code is in a
        better position to decide if this change is possible)


          • 4310
          • 2,310 Posts
          Your idea seems like it would work in most scenarios.
          I’ll have to look at the way aliases are formed.
            • 22303 MODX Staff
            • 10,725 Posts
            You can do this in Revo by changing the setting for alias paths on separate Contexts. Or at least if you can isolate the Resources you want to have full paths to one Context and those that do not to another.

            I do not think this is an easy change for Evo, though I can’t recall exactly why I believe that to be true. However, if someone comes up with a solution, we’d certainly be willing to implement it if tests determined it did not have any negative effects.
              • 4310
              • 2,310 Posts
              Thanks Jason.
              Quick testing shows changing :
              manager/processors/save_content.processor.php
              Modx 0.9.6.1 @ line 869 & Modx 0.9.6.3 @ line 707 from ->
              $alias = preg_replace('/[^\.%A-Za-z0-9 _-]/', '', $alias);

              to ->
              $alias = preg_replace('/[^\.%A-Za-z0-9 \/_-]/', '', $alias);

              seems to work okay.
              Other illegals still are converted, but forward slashes are retained.
              FURL navigation continues as normal.
              Would anyone else would like to test and report back?
                • 3177
                • 137 Posts
                Just tested this on 0.9.6.3 and there is a problem with the solution.
                The url does work, the slash remains there.
                But when you use images in the document, the TinyMCE (or something else in MODX) makes the urls relative.
                So, an image resides in href="assets/imges/myimage.jpg".
                This is a relative url based on the url of the document. And then the images are not found.

                Regards,

                Bert
                  • 4310
                  • 2,310 Posts
                  Bert,
                  Inserting images via the File Browser or TinyMCE both work for me on a page using a / in the document alias.
                  Do you have <base href="[(site_url)]"></base> or something similar in your template?
                  Or maybe your TinyMCE Plugin Configuration is different to mine, (I have Path Options : docrelative)?
                    • 3177
                    • 137 Posts
                    David,
                    I also have Docrelative in my TinyMCE settings, this seems to be the default.
                    But I don’t see my imagesin the browser, although I do see them in the MODX-edit-page.

                    I changes the TinyMCE to rootrelative and it worked, however I have to add the slash to all images
                    in the HREFs on those pages having a slash in the document alias.

                    I do NOT have a BASE tag in my template? Should I add that?

                    Bert
                      • 4310
                      • 2,310 Posts
                      I think almost everyone uses the <base> tag, mainly to avoid issues with relative url’s.
                      Try it and see if it solves the image issue.
                      I didn’t have to add any forward slashes when using TinyMCE to insert an image, or when using the File Browser from a TV.