We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16732
    • 592 Posts
    This is an auto-generated support/comment thread for Xternalinks.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Automatically add a specific css class to a link according to a part of this link.
      • 32514
      • 11 Posts
      Is there a way in which this could be configured to not apply to XML file types as it breaks the sitemap.xml and, no doubt, the RSS feeds?
      Thanks.
        • 16732
        • 592 Posts
        Are you sure that is Xternalinks who breaks the sitemap.xml ... this file does not have any <a> tag so the plugin should not interfere with it.
          • 4095
          • 372 Posts
          I’m guessing this would not be easy to do; but would be cool if it could add a class based on the extension / file type.

          So anytime a PDF document was linked it would assign it a class so I could use a PDF icon. This is done in the Filedownload snippet, but would be cool to do on any matching link on any page.
            [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
            Admin Sandbox Login: sandbox Password: castle
            • 16732
            • 592 Posts
            Yes... I will see what I can do for file extensions support
              • 15082
              • 195 Posts
              Hi folks,

              when activating this plugin on MODx 0.9.6.2, the class for the internal links is insertet twice in the source code.

              <a href="linkedsite.html" class="internal" class="internal">linked site</a>
              


              Any Ideas?

              Best regards

              JUSI
                • 1416
                • 75 Posts
                Briggsy:

                If you still need the pdf, and doc and whatever you want, a friend of mine fixed it rather quickly.

                Find:
                $sites = explode('||', $Xterlink_sites);
                foreach ($sites as $key=>$value) {
                    $sites[$key]= explode('->', $value);
                }


                And add this after it:
                $custom = explode('||', $Xterlink_custom);
                foreach ($custom as $key=>$value) {
                    $custom[$key]= explode('->', $value);
                }


                And also find:
                        for($n=0;$n<count($links[2]);$n++){
                            $linkprotocol = strtolower(substr($links[2][$n],0,5));


                And replace with:
                        for($n=0;$n<count($links[2]);$n++){
                            $fileextension = strtolower(substr($links[2][$n],(strrpos($links[2][$n], ".")+1),strlen($links[2][$n])));
                            if (count($ext)>0){
                                foreach($ext as $customExt){
                                    if($fileextension==$customExt[0]){
                                        $o = str_replace($links[1][$n],$links[1][$n].' class="'.$customExt[1].'"',$o);
                                        $links[1][$n]=$links[1][$n].' class='.$customExt[1];
                                        continue(2);
                                    }
                                }
                            }
                            $linkprotocol = strtolower(substr($links[2][$n],0,5));


                Update the parameters with:
                &Xterlink_sites=<strong>Sites</strong>;string;www.modxcms.com->modxcmscomclass||modxhost->modxhostclass||modxcms.fr->modxcmsfrclass ;&Xterlink_genericclass=<strong>Generic external links css class</strong>;string;external   &Xterlink_internalclass=<strong>Internal links css class</strong>;string;internal
                 &Xterlink_httpsclass=<strong>HTTPS css class</strong>;string;httpsXternal &Xterlink_ftpclass=<strong>FTP css class</strong>;string;ftpXternal &Xterlink_custom=<strong>Custom protocol</strong>;string;javas->javascriptClass &Xterlink_ext=<strong>File extentsion</strong>;string;pdf->pdfclass||doc->docclass||html->htmlclass;


                Now you’re done and you can add whatever filetype you want.

                I use it in conjunktion with http://www.psyked.co.uk/css/automatic-link-icons-v20.htm so I can style the links with my css, and add jQuery to open the pdfclass, or whateverclass in a new window.
                _blank isn’t valid anylonger, though it works just fine.

                Greets go out to my friend bac0n who fixed this little script for me.

                Cheers
                  • 24250
                  • 18 Posts
                  Hi,
                  referring to this tho post jusicgn above.
                  Has anybody a solution for double/tripple or multi class="external" entry when the same links appear more often on one page?

                  regards