We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • As requested by someone on the #modx IRC channel, here is a short, sweet plugin for placing links in your content using the [~~] tag format by alias.

    Example usage:
    [~[+alias:actual-doc-alias-here+]~]

    This will return the relative link to the document using the proper alias (if friendly_alias_urls is enabled), prefix, suffix, and alias path (if friendly_alias_paths is enabled). Please note, you must have friendly_urls enabled to use this, and you must make sure that every alias exists that you create a link to, otherwise, the parser in 0.9.1 will return an error like this:
    Fatal error: Cannot use [] for reading in C:\dev\xampp\htdocs\modx\manager\includes\document.parser.class.inc.php(807) : regexp code on line 1
    



    Here is the plugin code:
    //AliasLinks plugin
    
    $e = &$modx->event; 
    switch ($e->name) { 
    	case "OnWebPageInit":
    		if ($modx->config['friendly_urls'] == 1) {
    			if (is_array($modx->documentListing)) {
    				foreach ($modx->documentListing as $linkAlias=> $linkDocId) {
    					$modx->setPlaceholder("alias:{$linkAlias}", "{$linkDocId}");
    				}
    			}
    		}
    		break;
    
       default :    
          return; // stop here - this is very important. 
    }


    You’ll need to enable the plugin for the OnWebPageInit event. Let me know if you have any questions.
      • 32241
      • 1,495 Posts
      Will this be added to the future release?
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 27385
        • 15 Posts
        This is an AMAZING plugin! It should receive much more credit on the site! Good work!

        -Andy
          • 6726
          • 7,075 Posts
          Agreed Andy !

          How did I miss that ?!?

          It will be most certainly be of great use grin
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 32241
            • 1,495 Posts
            Added to repository
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 32241
              • 1,495 Posts
              Quote from: OpenGeek at Feb 28, 2006, 08:30 PM

              Also, if you want to build them using the alias instead of the id, you can take a look at my AliasLinks plugin at http://modxcms.com/forums/index.php/topic,2763.0.html -- you could use those in conjunction with #anchor links as well, like so:
              [~[+alias:somepagealias+]~]#anchor

              This might be useful for creating portable content dependent on aliases instead of document ids.
              And FYI, [*alias*] only gets the current document’s actual alias, not the full alias path as is applied via the [~~] tags, but this may be possible with the plugin, though I haven’t tried it:
              [~[+alias:[*alias*]+]~]#anchor


              Just some other options I wanted to point out.
                Wendy Novianto
                [font=Verdana]PT DJAMOER Technology Media
                [font=Verdana]Xituz Media
                • 4273
                • 356 Posts
                I don’t get it how does this work ?

                [~[+alias:actual-doc-alias-here+]~]

                i tried it but no link [~[+alias:aliasname+]~]

                are we suppose to put doc id with it ?
                  SMF Bookmark Mod - check it out
                  http://mods.simplemachines.org/index.php?mod=350
                  • 21908
                  • 8 Posts
                  I will renew this topic, because i also have the problem with creating alias links. I have the newest veriosn of modcsms
                  I installed, and enabled the plugin, but it doesnt work.

                  When i try to link, the tag [~44~] works fine, and outputs a firendly link to http://mysite.com/category/alias-for-id-44.html but

                  the command [~[+alias:alias-for-id-44+]~] doesnt work at all. I recieve a link which looks like that http:/mysite.com/[~~]
                  I tried many combinations of [ ] [[ ]] [++] [~~] but none was working

                  Has anyone solved this clue?

                    modx is amazing and brilliant. So is modx community!
                    • 33582
                    • 80 Posts
                    I have the same problem. Has enyone found a solution ?

                    Regards.
                      Aur
                      • 36695
                      • 47 Posts
                      AliasLinks was working fine on my site until I added the PHx plugin. Now it doesn’t work at all. It looks like PHx somehow strips the alias: placeholder. Any ideas on how to get around this?