We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3570
    • 9 Posts
    Hello everyone. This is my first post on this forum so I hope I have chosen the correct area. Apologies if that is not the case.

    I am trying to find a way of linking variables to an uploaded file. For example, suppose I wanted to be able to upload a file and at the same time supply an author name, title and number of pages.

    I then want to be able to add a snippet of code to a template that will output a table with a link to each of those files and containing the author name, title and number of pages.

    I’m reasonably proficient with PHP and MySQL, but I have no idea how to setup this kind of functionality within the MODx Manager interface.

    Is there any way of doing this?

    Thanks
      • 16034
      • 107 Posts
      If you want to code it yourself from scratch a solution is to make a module in the manager for uploading and editing a custom database table. And then create a custom snippet for showing the content from that table.

      I don’t know how much of the above you would be able to do without writing it yourself. The showing of content could probably be done with Ditto.
        MODx snippet-glossary 101:
        Ditto = Content Lister -- Wayfinder == Menu Builder -- Jot = Comment Control
        • 7231
        • 4,205 Posts
        How many books will there be? If you are talking about a library then you will be happiest with a module as described by Kleist. However, if you are talking about a limited number of books then you can use the modx document structure as data storage rather than web pages. Then use TVs to setup all of the additional fields and the upload filed. In order to hide the content field and other unused fields in the Manager you can use the ManagerManager plugin. Finally use a snippet like Ditto to create the display.

          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 3570
          • 9 Posts
          Thanks for your replies.

          @ Kleist:

          Coding a module myself would be a last resort, since obviously being new to MODx it would probably take me a considerable investment of time.

          I don’t know too much about Ditto. I’ve heard it mentioned a few times though so it sounds like something I should look at.

          I believe that there are a few different ways of displaying the information - and Ditto is probably one of them. The bit I am most worried about is finding a user-friendly way of getting the data in.

          @ dev_cw

          There would be between 5 and 20 books. The end user would be adding and removing maybe one or two books per week.

          "However, if you are talking about a limited number of books then you can use the modx document structure as data storage rather than web pages. Then use TVs to setup all of the additional fields and the upload filed."

          I want to have a way of doing this that is user-friendly, so I can open it up to clients. I want them to be able to upload the file and provide the title and author at the same time... Rather than having to upload the file, remember the file path, and then add the title and author afterwards. Would your suggestion fit that criteria, and if so, could you please provide a bit more information on how this would be setup?
            • 7231
            • 4,205 Posts
            Would your suggestion fit that criteria, and if so, could you please provide a bit more information on how this would be setup?
            Yes. This is also easy for clients to understand since it will be the same process as adding new pages, news articles or blog posts. So you only need to teach the client one process that will be used throughout.

            1) create a ’blank’ template to use for the documents. I like to add a redirect snippet just in case the document gets visited (I like phiRedirect for this).
            2) create a container document in your Document Tree (in the Manager) to store the data for the books.
            3) create a File type TV and assign it to the template we created. The File type TV will provide allthe tools fr uploading and managing files and the path tothe selected file will auto populate.
            4) Create any other ’additional’ fields that you will need as well such as author. However try to use the existing document fields when possible.
            5) Install the plug-in ManagerManager to personalize the content editing section of the manager by hiding the unused fields and renaming existing ones to fit the requirements.
            6) as a final touch you can add a shortcut link (or button) to the manager "home" page to make it easy for the client to add new books.

            Then use Ditto to display the index of Books and use custom display tpl chunks to make it look the way you want.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 3570
              • 9 Posts
              Thanks dev_cw. That sounds like what I’m after. I’ll try it out later and post how I get on.
                • 3570
                • 9 Posts
                Great. Got it sorted out and it works a treat.

                I was actually using this to create a XML mp3 playlist for integration with the JW flash mp3 player. I didn’t want to say that in case I was referred to one of the other MP3 playlist related threads that I found were pitched beyond my newbie understanding of MODx.

                Anyway, I have got it done now and it works well.

                I will try and post the steps I went through over the next few days - in detail and in newbie-friendly language. That may help others in future.

                That’s all for now.