We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30703
    • 51 Posts
    Hi,

    I've created a really helpful snippet to be used as an output filter, and I would love to offer it back to the community. Question is, where should I put it?

    It's a small snippet that wraps <a> tags around any URL or email address it finds. It will deal with email addresses differently (to add the mailto: protocol) I've tested it on many different URLs, and it works exactly like Outlook does (converts www.google.com into a clickable link, as well as http://www.google.com or https://www.google.com/ etc.)

    How do you package things like this? Should it go into the package management area, or just be on the forums for users to find on their own?

    Comments and thoughts appreciated smiley

    Also, let me know if you need something like this in the meantime and I'll post it. Cheers!

    This question has been answered by multiple community members. See the first response.


      Tom Dyer

      Designer/Animator/Web Developer - England, UK.
      http://www.bespokepixels.co.uk
    • discuss.answer
      • 3749
      • 24,544 Posts
      You could package it with PackMan and submit it to the repository at modx.com/extras. Often stuff like that is posted in the "In Development" forum for feedback before a public release.

      You might also consider making a plugin version attached to OnDocFormSave so it would only run once when the resource is saved instead of every time a page is requested, though you'd have to make sure it recognized ones that had already been transformed.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 30703
        • 51 Posts
        Thanks BobRay,

        It wouldn't affect links that are already setup since it's using a Regular Expression to look for urls and emails that don't have <a> tags around them smiley

        I've been using it on my email template for FormIt, so when people type www.mysite.com the link comes through as clickable in my html email.

          Tom Dyer

          Designer/Animator/Web Developer - England, UK.
          http://www.bespokepixels.co.uk
        • discuss.answer
          • 3749
          • 24,544 Posts
          It's a great idea. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 30703
            • 51 Posts
            Check out an example of my wrapURLs output filter here:

            http://www.kick-as3.co.uk/development-tests/wrapurls.html

            As you can see in the example, you can pass in link attributes such as class="myclass" or target="_blank" (target attribute gets stripped from mailto: links since it tends to leave a blank tab open otherwise)

            I'll be doing some last minute tests later on, then packaging it up if everything goes well smiley

              Tom Dyer

              Designer/Animator/Web Developer - England, UK.
              http://www.bespokepixels.co.uk