We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36686
    • 165 Posts
    I'm trying to figure out how to do a basic MIGX within a MIGX. It's for an FAQ and all I'm after is having Categories which contain Questions and Answers:

    Category A
    - Question 1
    - Answer 1

    - Question 2
    - Answer 2

    Category B
    - Question 1
    - Answer 1

    etc.

    I've got the Questions and Answers set up with no problem.

    Form tabs:

    [{"caption":"FAQ", "fields": [
        {"field":"question","caption":"Question"},
        {"field":"answer","caption":"Answer","inputTV":"richtextTV"}
      ]
    }]


    Grid columns:

    [{
      "header": "Question", "sortable": "true", "dataIndex": "question"
    },{
      "header": "Answer", "sortable": "false", "dataIndex": "answer"
    }]


    Is there a simple way to add Categories (preferably that I can drag and drop the questions between)?

    This question has been answered by Bruno17. See the first response.

      • 4172
      • 5,888 Posts
      what about having a Listbox with categories, where to select the category from?

      If you create your categories by Resources, you can use a @EVAL - binding to get the input-options for the listbox.
      On the Frontend you could use getResources for listing the categories and inside the getResources-Tpl you can use a getImageList-call to get the by category(resource-id) filtered MIGX-items.

      Of course its also possible to have an outer MIGX-TV for the categories and an inner MIGX-TV for the question/answers.
      But drag/drop between categories isn't possible this way.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36686
        • 165 Posts
        Thanks @Bruno17 for your quick response!

        I didn't think about the possibility to use the @EVAL binding to retrieve the categories, this is definitely an option.

        I would however prefer to keep everything in just one resource if possible, as I think this makes more sense to my clients when they edit the content. Are you able to explain the basics of how I would go about setting up an outer and an inner MIGX TV?
        • discuss.answer
          • 4172
          • 5,888 Posts
          you can create another MIGX-TV inside the outer MIGX-TV by adding a migx - inputTV into the formtabs:

          The formtabs for the outer MIGX-TV (FAQcategories):

          [{"caption":"FAQ Categories", "fields": [
              {"field":"category","caption":"Category"},
              {"field":"faqs","caption":"FAQs","inputTV":"FAQsTV"}
            ]
          }]


          The formtabs-configuration for the inner MIGX-TV (FAQsTV)

          [{"caption":"FAQ", "fields": [
              {"field":"question","caption":"Question"},
              {"field":"answer","caption":"Answer","inputTV":"richtextTV"}
            ]
          }]


          To get them printed on the frontend, this should work:

          [[getImageList? &tvname=`FAQcategories` &tpl=`tplFAQCategory`]]


          The tplFAQCategory - chunk:

          <h3>[[+category]]</h3>
          [[getImageList? &value=`[[+faqs]]` &tpl=`tplFAQ`]]
          



            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 36686
            • 165 Posts
            It works brilliantly, thank you so much! I'm sure this will come in handy in other situations too.

            One last question - on my resource on the TV tab, under FAQs, before you click the category to edit it, it says [{MIGX_id":"1","question".... etc. etc. Is there any way of hiding this column so admins don't need to see it? Apart from scaring some admins I'm worried it's gonna get really long once you get a few FAQs in there.
              • 4172
              • 5,888 Posts
              In Columns, you don't need to have all fields, you just need

              [{
                "header": "Category", "sortable": "true", "dataIndex": "category"
              }]


              as the only one column in your grid
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 36686
                • 165 Posts
                Of course, got it. Thank you so much for your help! I think I'm finally starting to get my head around MIGX now, after a few years of using it smiley

                PS. Love MIGX btw – MODX wouldn't be the same without it!
                  • 36686
                  • 165 Posts
                  While we're at it... I'm trying to sort alphabetically by the question like this:

                  &sort=`[{"sortby":"question","sortdir":"ASC"}]


                  It works fine in my local development environment with PHP 5.4.10, but when I upload to my client's site with PHP 5.3.3 I get this error:

                  Warning: Parameter 2 to array_multisort() expected to be a reference, value given in /....../core/components/migx/model/migx/migx.class.php on line 1257

                  I posted in this thread where someone else has the same issue: http://forums.modx.com/thread/77554/how-to-proper-use-sort#dis-post-485078
                    • 37042
                    • 384 Posts
                    Hi Sketchi

                    Can I ask how you got your actual FAQs to display?

                    I have a getImageList call as follows

                    [[getImageList? &tvname=`FAQcategories` &tpl=`TPL-Category`]]


                    and inside that I have:

                    <h3>Category: [[+category]]</h3>
                    [[getImageList? &value=`[[+faqs]]` &tpl=`tplFAQ`]]


                    It sucessfully displays the Categories in H3 headings but no actual questions and answers are displayed.

                    I suppose I need to know what actually goes in the chunk called
                    &tpl=`tplFAQ`


                    Thanks for your help
                      ...
                      • 4172
                      • 5,888 Posts
                      what do you get with:

                      <h3>Category: [[+category]]</h3>
                      [[+faqs]]
                      


                      you need to use this placeholders in the tplFAQ:

                      [[+question]]
                      [[+answer]]


                      if you have this fields in your formtabs for the inner MIGX
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!