We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35395
    • 12 Posts
    Hello ModX community. I've done some basic html/css/php/javascript web development tinkering for awhile, and after a brief introduction to Drupal, ModX is a breadth of fresh air! Anyway, I'm a newbie and still learning some of the basics, so I wondered if any folks would like to share an approach to accomplish my task (by approach I mean which modules and in a very general way, how to utilize them).

    My goal is to create a custom media object and browser/player/viewer of said media resources for a speaker or lecturer. Users should be able to browse entries by topic, date, references, etc.. and an entry would have an audio file associated with it, but it should also have the ability to have a video and transcript when available for the talk. I'm picturing a custom media object (TV's?) that would have some of the following fields:
    - Date of lecture
    - Title of talk, Description
    - Name of Speaker
    - Textual and Numerical reference to book being lectured on
    - audio file
    - video file (if available)
    - written transcript (if available)

    Hopefully this gives the basic idea of what I'm going for. Someone should be able to find particular talks and lectures by utilizing some of the fields above for browsing/categorization, and when they find an entry they are interested in they should be able to get at the audio, video, or transcript.

    Thanks for any help on directing me toward the right approach and/or add-ons.
      • 37059
      • 368 Posts
      I would do it (and in fact I have done something comparable) with resources and template variables as you mentioned. You can use form customization to format the input so all the fields you need are on the primary tab. On the fontend, you can use output filters such as 'notempty' to show certain elements only if they are available for that resource. For instance, the video player would only appear if there was a value in the "video" tv.

      For cataloguing the lectures, you shouldn't need much more than getResources and maybe a tagging plugin.
        Jason
        • 35395
        • 12 Posts
        Thanks polrbear! That's a great start. One thing I played around with briefly and couldn't quite get working was an easy way to be able to choose and upload a file at the time of adding the resource. In other words, a content editor who adds a "lecture" should be able to associate the "audio" or "video" TV with a local file and have it upload into a specific directory automatically. Is this possible?
          • 37059
          • 368 Posts
          Yup - just use the tv type "file" and set the base dir appropriately. When your content editors go to add a video, they'll have the option to upload a new file to that directory using the MODx file manager system.
            Jason
            • 35395
            • 12 Posts
            As a followup,

            I have been reading the modx official guide and it suggests that in situations where there are going to be many entries using resources might really hit performance and quickly become unmanageable. It suggests instead using a custom database and just having the fields needed. By xPDO-ing the database I would be able to use all those xpdo db functions. So let's say I have 500 lectures. Should I still go with the resource/TV approach? How about 1000? These are weekly so we are talking about 50 a year.
              • 37059
              • 368 Posts
              On the forums I remember someone saying that you should really go with a custom DB if you've got more than 100 entries. Naturally this approach multiplies the complexity of the project, particularly on the manager side as you can no longer use the built-in functionality of resource editing and TV's. So it's a tradeoff.
                Jason
                • 35395
                • 12 Posts
                I'm kind of upgrading an old system actually. I'm kind of a noob and learn as I go along, but before using modX I built a pretty simple but functional version of this using php and a custom db. I made a very plain vanilla front end page with a form so that someone could create new entries. It wasn't very robust but I figured I could just go in to myPhpAdmin and fix any mistakes as needed. It works ok, but now that I am re-doing the site in ModX I was looking forward to doing something a little next level. I should probably try to go the db route even though there are going to be more things to learn.
                  • 3749
                  • 24,544 Posts
                  Since you already have the table(s), you might find this approach helpful for making them xPDO-friendly: http://bobsguides.com/custom-db-tables.html.

                  If there are multiple tables with relationships between them, you'll have to modify the schema manually, but this will get you started. If it's just one table, this method is fairly quick and easy.
                    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
                    • 35395
                    • 12 Posts
                    Bob,

                    Wow! That was a very helpful write-up. Honestly the hardest part of xPDO-ing my custom table was the re-working and cleaning up of the data to accommodate some of the new ideas I have. Once I got the actual table created it was really easy. I briefly looked through the rest of the tutorial and was delighted to see that there are instructions on making input forms too since I will absolutely need that.

                    I can probably rumble around and figure this out, but if you know how to achieve this and it's easy to describe...

                    First imagine the following table with two columns...

                    A | "1, 3, 5, 9"
                    B | "8, 5, 3, 5"
                    C | "9, 2, 2, 3"

                    I would like to create a form for content managers to enter data into another db table but would like to use the table above to drive a couple of select lists in the form. The first select list should show all the values in the first column (A, B, C, ...). Then, based on which one is selected, a second select list should show the corresponding options, which in this case, is actually a varchar field which is a comma delimited string.

                    I think I've seen code to explode a comma delimited string into an array, but any other advice would be great.
                      • 3749
                      • 24,544 Posts
                      It's relatively easy to create the form dynamically by looping through the options and adding them to the $output variable:


                      <?php
                      /* get $data from table here */
                      $output = '<select name="list1" id="list1" size="4">';
                      $options = explode(',', $data);
                      
                      foreach ($options as $option) {
                          $output .=     '<option value="1">' . strip($option) . '</option>' . "\n";
                      }
                      $output .= '</select>';
                      
                      return $output;
                      
                      


                      If you want the second select list to be populated and appear when the first selection is made (rather than having them submit the form), you'll have to use JavaScript.
                        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