We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46950
    • 86 Posts
    I try to use MIGX and do everything according to a tutorial. I created a table which consists of three fields: Day, From and Until. Then I put in two lines but the chunk which must display the data shows me only the word "Closed". So it looks like it cannot read the data. How can I make it work? The chunk is this:

    <tr>
    <td>[[+day]]</td>
    [[+from:notempty=`<td>[[+from]]</td><td>[[+until]]</td>`:default=`<td colspan="2">Closed |[[+from]]|</td>`]]
    </tr>

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

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You need to use one of the MIGx output snippets to get the values from the TV. The chunk is only the tpl, the structure used to display each item being output.

      Which tutorial are you using?
        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
        • 46950
        • 86 Posts
        Yes, I have installed this snippet. I use a Russian tutorial which evidently is based on some tutorials in English. The author of the russiqn tutorial mentioned the fiorst one on this page http://codingpad.maryspad.com/beginner-tutorials/ as the source of his tutorial, but this tutorial doesn't contain the lesson #14, so I don't know what source he used.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Hm. Well, without more information on what you are trying to do, I can't really help much.
            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
            • 46950
            • 86 Posts
            I do everything according to the Russian tutorial:

            1) Creating TV operatingHours, its Input Type is migx.

            2) Form Tabs for the TV:
            [
            {"caption":"Operating Hours","fields": [
            {"field":"day",
            "caption":"Day"
            },{
            "field":"from",
            "caption":"From"
            },{
            "field":"until",
            "caption":"Until"
            }
            ]
            }]

            Grid Columns for the TV:
            [
            {"header": "Day", "width": "60", "sortable": "false", "dataIndex": "day"},
            {"header": "From", "width": "50", "sortable": "false", "dataIndex": "from"},
            {"header": "Until", "width": "50", "sortable": "false", "dataIndex": "until"}
            ]

            3) Adding two (or more) lines with date to the table (manually, in the tab Template Variables).

            4) Adding this to the field Content:
            <table>
            [[getImageList?
            &tvname=`operatingHours`
            &tpl=`operatingHoursTpl`
            ]]
            </table>

            5) Creating the chunk operatingHours:
            <tr>
            <td>[[+day]]</td>
            [[+from:notempty=`<td>[[+from]]</td><td>[[+until]]</td>`:default=`<td colspan="2">Closed</td>`]]
            </tr>

            6) Adding [[$operatingHours]] to where I'd like to see the schedule. But seeing only "Closed" sad
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              The chunk you named "operatingHours" is supposed to be "operatingHoursTpl", and act as the tpl to provide the HTML code for each item in the list. It is not called directly in the page, the getImageList snippet uses it internally.
                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
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Here's sample results on one of my local testing installations, in the main area between the left column and the right column you can see the table with two entries.
                  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
                  • 46950
                  • 86 Posts
                  Quote from: sottwell at Aug 05, 2014, 10:33 AM
                  The chunk you named "operatingHours" is supposed to be "operatingHoursTpl", and act as the tpl to provide the HTML code for each item in the list. It is not called directly in the page, the getImageList snippet uses it internally.

                  Sorry, surely the name of the chunk is operatingHoursTpl. But you say that the way I call the chunk is wrong? Must I call it not [[$operatingHoursTpl]] but in a different way? I've tried [[$getImageList]] but it doesn't work either.
                  • discuss.answer
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Create the chunk "operatingHoursTpl" as the tutorial says. You will not use this chunk. You tell getImageList to use it as the tpl.

                    Just put the getImageList snippet where you want the table to be displayed.
                    <table>
                    [[getImageList?
                    &tvname=`operatingHours`
                    &tpl=`operatingHoursTpl`
                    ]]
                    </table>
                      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
                    • discuss.answer
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      What this is doing is telling the getImageList function to get each row of your MIGx TV operatingHour's grid, and apply the chunk operatingHoursTpl as the template for the output of each row. Here is the resulting HTML output from my test:
                      <table>
                      <tr>
                      <td>Saturday</td><td>10</td><td>2</td>
                      </tr><tr>
                      <td>Sunday</td><td>12</td><td>4</td>
                      </tr>
                      </table>

                      You can see that each row is made from that operatingHoursTpl chunk, repeated for each row. The getImageList does this automatically.
                        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