We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20499
    • 4 Posts
    We are migrating our current website from a CMS called Revize (payware) to ModX smiley. I am using Ditto to create a "Quick Links" menu on the left of the page. It grabs the documents under each department’s page and displays those in a list. Is there any plugin/extension/way to have a browse button next to the weblink field? I’m envisioning it to be like creating a link with TinyMCE where you can either type in a URL, browse to a file such as a pdf, or select a page in ModX. At the moment, I’m having user’s upload their file with the file manager, then copy/paste the path and filename into the weblink field. It works, but It’s kind of a hassle.

    Any suggestions or help is very much appreciated. Thanks!

    - Matt
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can use TVs with weblinks, and have Ditto make its links from the TV instead of the usual id or whatever. A file input type TV has uploading of files to the assets/files directory. Make sure the weblink is set to not show in the menu, or Wayfinder will be very unhappy about it not having a proper URL (or document id) in the weblink field; that is, if it doesn’t have a proper URL as well as the TV with the path to the file.

      When testing this, I used a TV named Files with the input type of File. Then I used this (very simple) chunk tpl for Ditto
      <a href="[+Files+]">[+menutitle+]</a>

      gives me a link to the file quite happily. I suspect that if you are using Ditto with mixed documents you could use PHx to determine the type of the document Ditto is working on at the moment and use two different chunks, depending on if the document type is "reference" or "document".
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 20499
        • 4 Posts
        Thanks for the quick response and suggestion. Got this working after only an hour of reading documentation, installing phx, and playing around with the syntax. For others that may care, Here’s my tpl chunk that selects the TV or link based on if the TV is empty

        <li><a href="[+QuickLinkDocument:ifempty=`[~[+id+]~]`+]" [+link_attributes+]>[+pagetitle+]</a></li>


        It’s amazing how flexible Modx is when you really start digging. Thanks all!!

        Now on to documentation for the end users...
          • 15566
          • 73 Posts
          I have just uploaded a plugin that fixes this by adding a ’Insert’ files button next to the weblink field:

          http://modxcms.com/extras/package/640
            • 20499
            • 4 Posts
            Keiron,

            Thanks, this is exactly what I was looking for! A few questions though:

            1 - Any reason your only allowing the button to show on ’blank’ templates? On our site, all new documents inherit the parent’s template, so I’d have to remove this condition, but want to make sure there wasn’t any specific reason (stability?).

            2 - Is there any way to make the button look like the browse button in the link manager? Many of our users are not web savvy, and would appreciate consistency (to them, browse = pdf).

            3 - Any plans you know of to include this as a standard feature in future releases? I think this is something many others would appreciate as well.

            Thanks!
              • 15566
              • 73 Posts
              Glad you like it. It’s the first plugin I’ve made and I did it because I needed it for some of my clients.

              1. I did make it only work on blank templates so that there weren’t clashes of javascript functions if they were already used as a template variable. Thinking about it I can just rename the function to stop this happening.

              2. Good idea - I’ll do this

              3. No idea. And I don’t know how this gets suggested to the people in charge.

              I have just made a small mod today so I will incorporate points 1 & 2 when I update the script online later (hopefully).
                • 15566
                • 73 Posts
                I updated the script last night with renamed JS functions and a fix for IE8. The icon was trickier than expected in the 1/2 hour I had - but it is achievable, so I will get around to it soon.
                  • 18668
                  • 25 Posts
                  What a superb idea! This would be really useful on a couple of MODx sites I run. Unfortunately the resource link seems to be broken so I can’t download it - can you look into it please? Ta.
                    ******************
                    Matthew Dawkins
                    www.matthewdawkins.co.uk
                    We make web sites for churches
                    Follow me on Twitter: twitter.com/chapter9
                    ******************
                    • 15566
                    • 73 Posts
                    I didn’t realise it was broken. I have reattached the file and it’s working now. I plan to update the button visually soon (when I get 10 minutes).
                      • 30912
                      • 463 Posts
                      Thanks for this its a big help, i dont suppose it could be modded to be on preRender, so its already there if the insert is on a default page, i.e a template called Links, which automatically has the button there?

                      GFood woork tho