We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29635
    • 361 Posts
    The Man Can! Reply #1, 20 years ago
    UPDATE: This plugin is now in the resource library. Please use that here:
    http://modxcms.com/Custom-Alias-1551.html
    New support thread:
    http://modxcms.com/forums/index.php?topic=16709

    =====================================================

    Hello all.
    My first stab at a plugin that’s pretty basic and really (really) heavily based on Mitch’s AutomaticLongtitle (thanks Mitch). Made it for a site where the pagetitles were used for SKUs, and the longtitles were what I actually wanted the SEF URL to be based on. This plugin checks to see if an alias exists, and sets the alias to longtitle.pagetitle if an alias is not set. So, pagetitle=TT3209 and longtitle=14k Gold Ring, alias would equal "14k-gold-ring.tt3209".

    Check off OnDocFormSave.

    (Code removed. Please get it here.)

    UPDATES:

    • v.96: Added Ryan’s better conversion array and a few other minor tweaks.
      [list][li]v.90: Fixed to work with 0.9.5.1+. Added more "documentation" and options, including the ability to use the ID of newly created documents. Upgrade to this version if you’re using 0.9.5.1 or higher.
    • v.85: Now converts accented characters to their non-accented counterparts.
    • v.86: Removes apostrophes from the generated alias.

    I imagine the usefulness of it is more in the ability to create your own schemes like longtitle.id or maybe setting the alias from the menutitle or something other than the pagetitle.

    Thanks for your input. And thanks again to Mitch’s original plugin.
    Once I can make sure this’ll work with 0.9.6 final I’ll post in the repository.

    -Brett[/list]
      Need MODx Ecommerce? Try FoxyCart!
      • 32982
      • 674 Posts
      a usefoul plugin thanks for me is very usefoul for take the alias in a spanish way whith ñ->n á->...
      thanks very much for sharing
        Jabiertxof (formerly XYZVISUAL)
        My bussines: http://marker.es
        https://www.youtube.com/user/jabiertxof/videos
        • 6726
        • 7,075 Posts
        Nice plugin smiley

        I’ll give it a look...

        One thing I sure would like to see for auto-generated alias is the ability to auto-generate nice alias for us accented characters foreign languages... for instance if I have a document named "généralités" the auto-generated alias will be : "gnralits", instead of "generalites"...
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 32982
          • 674 Posts
          you only need to the plugin codes to all special character
          example
          $alias_new = str_replace(’Ü’,’U’,$alias_new);
          $alias_new = str_replace(’é’,’e’,$alias_new);
          $alias_new = str_replace(’ñ’,’n’,$alias_new);
          think is the way...
            Jabiertxof (formerly XYZVISUAL)
            My bussines: http://marker.es
            https://www.youtube.com/user/jabiertxof/videos
            • 29635
            • 361 Posts
            The Man Can! Reply #5, 20 years ago
            New code posted (above) that converts accented characters to their non-accented counterparts. I’m getting the feeling that maybe I should change the default settings of this plugin from the "longtitle.pagetitle" output that it currently has to something more universal, like just plain "longtitle" or "pagetitle".

            Thoughts? This could be combined with AutomaticLongtitle, and the aliases could be based on the longtitle by default. Would probably be more useful for most people (especially the non-English users?) out of the box, but let me know your thoughts.
              Need MODx Ecommerce? Try FoxyCart!
              • 32982
              • 674 Posts
              only a point i think one way is parametrizer the option to set longtitle or menuindex or pagetitle or....
              because it this plugin could be used for example to only a folder of the proyect....
              hi
                Jabiertxof (formerly XYZVISUAL)
                My bussines: http://marker.es
                https://www.youtube.com/user/jabiertxof/videos
                • 3493
                • 66 Posts
                Ah, great! This is a plugin I’ve been looking for laugh
                Now, I’m using ModX for a small newspaper that wants to put fractions of the paper out on the web to ’tease’ people to buy it. It’s working great so far, since I’m using the NewsListing snippet to list the weeks news, but the pages with the news gets one heck of an alias, since it’s based on the Long title variable. The editors that are using ModX, doesn’t want to fill in a simpler alias every time they’re generating a page, so this plugin (in a tweaked form) will probably help me.

                Instead of generating an alias based on "$_POST[’longtitle’]" and "$_POST[’pagetitle’]", how can I make it read the page-ID, and use this as an alias instead?
                  • 29635
                  • 361 Posts
                  The Man Can! Reply #8, 20 years ago
                  $_POST[’id’] wink
                  You might want to experiment with createdon or pub_date as well, as that might make more sense if the pages you’re generating are based on the date.

                  Also, make sure you modify this line:
                  if ($_POST[’alias’] == ’’ && $_POST[’longtitle’] != ’’)
                  if you need to. Right now it’s checking to see if the alias is empty and the longtitle is not empty. You might not need the longtitle check.
                    Need MODx Ecommerce? Try FoxyCart!
                    • 13993
                    • 100 Posts
                    Be careful using the long alias as the url. If your url is too long, there is a chance the SE’s will choke on it.

                    From: http://www.mattcutts.com/blog/guest-post-vanessa-fox-on-organic-site-review-session/
                    But you can have too much of a good thing. It also doesn’t take a special tool to know that this page name isn’t user-friendly:

                    african-elephants-and-their-habitats-and-diet-and-history-and-extinction-possibilities-and-this-page-is-really-great.html

                    Even Matt Cutts from google is using semi long file names, but there is always such a thing as too much.
                      • 3493
                      • 66 Posts
                      Thanks for your help The Man Can! I’ll try it out smiley
                      Jeremy’s reason is exactly why I’m using DocID and maybe also a date to generate the alias... I recommend the same to everybody else!