We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13993
    • 100 Posts
    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!

    I disagree with that. On the same blog, Matt says that using keywords in the url is a positive thing for search engine rankings. I was just saying watch out how long they get. I personally try to use the short title.
      • 27889
      • 415 Posts
      I wrote a such function for my TOC plugin, it could be usefull to remove HTML tags and all others chars:
      $search=array('/<[\/\!]*?[^<>]*?>/si','/([\r\n])[\s]+/','/[^_A-Za-z0-9\-]/');
      $replace=array('');
      $alias_new=preg_replace ($search, $replace,$alias_new);
      


      Perhaps include the replace_char function in the MODx API.
        MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
        MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
        • 3493
        • 66 Posts
        Yeah, you’re right. I’ll take back my statement.

        But there’s something fishy going on with the $_POST[’id’]-value. It seems that it turns a few numbers into letters for the documents I’ve already created. When I made a new page last night, the doc-ID seemed to work fine, but again, for documents already created, CustomAlias creates a somewhat strange mix of numbers and letters instead of the plain doc-ID.
        Also, $_POST[’createdon’] is always empty, but I guess this might have to do with my old version of ModX (which I will upgrade very soon tongue).

        Example of wrong Doc-ID’s:
        64 = a4
        142 = c4u

        ModX-version currently running: 0.9.1
          • 27889
          • 415 Posts
          Can you give more and longer examples please.
            MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
            MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
            • 3493
            • 66 Posts
            No, sorry, that was all the examples I could provide...
            But anyways, I’ve recently upgraded to 9.2.1, but now the plugin won’t respond at all. When I leave the alias field blank and click save, nothing happens...

            I’ve activated OnDocumentFormSave and removed the "check long name" condition.
              • 29635
              • 361 Posts
              You may want to check exactly what you removed when you say you "removed the ’check long name’ condition"... You may have removed something that is necessary. It might be a better idea to swap ’longtitle’ with ’pagetitle’ where appropriate, rather than removing lines of code. Just a thought.

              Re: 0.9.2.1, I’ve only tested this on the betas and RCs of 0.9.5, where it seems to work great. I hope that helps.
                Need MODx Ecommerce? Try FoxyCart!
                • 3493
                • 66 Posts
                You are probably right, Can Man, since I’m a beginner on this stuff... I’ll check it out closer, even though I’m quite sure I haven’t modified the code wrong.

                Again, thanks! I’ll be back with more information as soon as possible.
                  • 3493
                  • 66 Posts
                  I solved the problem above by upgrading my MODx installation smiley

                  But, I’m using the document ID to create the alias, but for new documents, the document ID does not appear until I save the document for the second time, by removing the alias name (because of the field check...).
                  I believe the problem here is that the document ID is generated by the system AFTER the CustomAlias has finished its process.

                  So is there any way I change this?
                    • 3493
                    • 66 Posts
                    ...Nobody? undecided
                      • 7923
                      • 4,213 Posts
                      Modify the plugin to get the highest ID number from the database and add one to it.

                      EDIT: $modx->db->getInsertId() returns the ID of the new document


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."