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

    I have a Migx running on a page which outputs a gallery of youtube videos to watch.
    It allows the user to add a title, and youtube id, and the tpl chunk outputs a nice thumbnail image, and a link to a modal popup window to view the video on the page.

    Occasionally, I need to have more than one video within the thumbnail (because they belong to the same campaign) so inside my tpl chunk I have this:

    [[+tv.YouTubeID2:notempty=`
    <li class="videopage">
    <a href="[[~[[+id]]]]" title="[[+pagetitle]]">
    <div style="background:url(http://img.youtube.com/vi/[[+tv.YouTubeID]]/0.jpg) no-repeat center / cover;"></div>
    <p>[[+publishedon:strtotime:date=`%b %Y`]]</p>
    <h2>[[+longtitle:ellipsis=`27`]]</h2>
    <span><p>Watch:</p><h3>“[[+longtitle]]”</h3></span>
    </a>
    </li>
    `:default=`
    <li>
    <a href="http://youtube.com/watch?v=[[+tv.YouTubeID]]?&autoplay=1&iframe=true&width=900&height=500" rel="prettyPhoto" title="[[+pagetitle]]">
    <div style="background:url(http://img.youtube.com/vi/[[+tv.YouTubeID]]/0.jpg) no-repeat center / cover;"></div>
    <p>[[+publishedon:strtotime:date=`%b %Y`]]</p>
    <h2>[[+longtitle:ellipsis=`27`]]</h2>
    <span><p>Watch:</p><h3>“[[+longtitle]]”</h3></span>
    </a>
    </li>
    `]]

    So what this is doing is outputting the first <li> if there is a second youtube ID entered, but if just one is entered, use the default and show the popup.

    This probably isn't the most efficient code, but it does work.

    But now, there are more variables coming into the pot, which i think is beyond my simplistic code.

    Now, within the galelry there could be:
    A: 1 video
    B: 2 or more videos
    C: A link to an external page
    D: A link to a downloadable PDF file

    But they all need to appear within the same gallery.

    Obviously I need to use different tpls based on whether the user chooses A, B, C, or D.

    I'm thinking of having a <select> menu in the backend, where i select A, B, C or D - and based on THAT selection, use a different TPL - but I have no idea how to go about this - and am worried that I'm going to have hundreds of TVs to cover all my bases!!

    Any ideas on a more suitable and manageable process for this?

    Thanks so much!

    Andy

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      this is possible with the multiple-formtabs-feature, like done here:
      https://rtfm.modx.com/extras/revo/migx/migx.tutorials/migx.varying-layout-boxes

      for 2 or more videos I would use a nested MIGX-field, where you can add as many vidoes as you like to each record.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 51020
        • 670 Posts
        Quote from: Bruno17 at Apr 19, 2016, 12:02 PM
        this is possible with the multiple-formtabs-feature, like done here:
        https://rtfm.modx.com/extras/revo/migx/migx.tutorials/migx.varying-layout-boxes

        for 2 or more videos I would use a nested MIGX-field, where you can add as many videos as you like to each record.

        Bruno - this is amazing - thank you. The varying layout boxes is a game changer for me - it means my layouts can be so much more flexible which is something I have struggled with in the past.

        I haven't got my head around how nested Migx fields work - but i will research it.

        Thanks so much for you advice - it really has helped massively!
          • 51020
          • 670 Posts
          One question on the varying layout boxes - I have tried to understand what is going on, and most of it makes sense, apart from this, which appears in each form tab:

          "field":"fake"
          ,"inputTVtype":"hidden"

          I don't understand the purpose of this?

          • discuss.answer
            • 4172
            • 5,888 Posts
            I'm not completely sure about that field, but I think, this was to have at least one field in the tab 'Row Format'
            If there isn't a field, the Tab wouldn't show.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 51020
              • 670 Posts
              Quote from: Bruno17 at Apr 20, 2016, 04:28 AM
              I'm not completely sure about that field, but I think, this was to have at least one field in the tab 'Row Format'
              If there isn't a field, the Tab wouldn't show.

              Ah OK thanks - makes sense - ish!
                • 51020
                • 670 Posts
                I have been playing with multiple form tabs but have hit a problem.
                I have a videos page, with a listing of videos.
                if there is just one video, it will open in a modal window, but if there are more than one video, it will open a page, with the thumbnail of each video, which in turn will open in a modal window when clicked.

                The single videos open perfectly as expected - as the chunk which renders them has all the code to fire the modal window and show the video.

                But - when there are two videos, I need to go to a page (resource) which displays both videos - but the resource doesn't exist - as this is all in Migx.

                I was originally using Collections and getResources to do this, but found the multiple form tabs much easier
                to manage, as i have various content items to add - but is there a way to do this via getResources - ie, load all the resources, but use a different TPL per item based on their content/template?

                I hope the above makes sense!

                Andy

                  • 51020
                  • 670 Posts
                  I just thought - cold I use &tplCondition somehow?
                  Ie, if the resource uses template 1 - then serve 1-Tpl, and if the resource uses template 2, serve 2-Tpl?
                    • 4172
                    • 5,888 Posts
                    this should do, what you want:

                    &tplCondition=`template`
                    &conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 51020
                      • 670 Posts
                      Quote from: Bruno17 at Apr 20, 2016, 01:12 PM
                      this should do, what you want:

                      &tplCondition=`template`
                      &conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`

                      Yep that works a treat - 'there's always a way with Modx'!!

                      Thanks again for your help.