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

    i'm pretty much new to the modx world. But as far as i can see for now, i like its ways very much.
    Now i try to grind through all my requirements to find a good way to implement them.

    I'm testing on revo 2.2.11

    So here is my question: Whats the best practice to implement an accordion in modx.
    As easy as this: http://mootools.net/demos/?demo=Accordion

    Its important the editors can pretty easy add and remove (maybe even sort?!) accordion items in the mgr from and to the accordion.

    one accordion entry is made of:
    - Headline
    - bodytext

    I'm able to set up the necessary tv's and chunks for that.
    But i have no clue how provide a reusable backend interface, so the editor can add as many items as he needs dynamically...


    In the moment I can only fake it like the Thema 1 to 4 in the screen shot:


    So how to do it the right modx way smiley
      • 30912
      • 463 Posts
      I would use MIGx for this - infact i Do use MIGx for it. (http://modx.com/extras/package/migx)

      Set up a MIGx tv - Accordion

      Form Fields

      [
      {"caption":"Panel", "fields": [
          {"field":"title","caption":"Title","inputTVtype":"text"},
          {"field":"text","caption":"Content","inputTVtype":"richtext"}
       ]
      }
      ] 


      Grid Columns:

      [
      {"header": "Title",  "sortable": "false", "dataIndex": "title" },
      {"header": "Content", "sortable": "false", "dataIndex": "text"}
      ]
      


      Accordion Chunk (this is your own accordion html/js btw)

      <h2 class="acc_trigger"><a href="#">[[+title]]</div><div style="float:left; width:30px;" ></a></h2>
      <div style="display: block;" class="acc_container">
        <div class="block"> [[+text]] </div>
      </div>
      


      Note the two fields are the same fields as what is in the TV.

      Create a chunk

      [[$Accordion]]

      and add this snippet to it.

      [[getImageList? &tpl=`Accordion` &tvname=`Accordion` &docid=`[[*id]]` ]]
      


      Then you place the [[$Accordion]] chunk anywhere you want the accordion to appear. if you want to sort them you can just drag and drop them in the MIGx grid to the order you desire.

      Theres more than one way to skin a cat in MODx though, but thats my way smiley
        • 41121
        • 27 Posts
        Hey Tyreal,

        nice! thx for the answer. I will try that.



        I will report back and flag the thread as solved when i succeeded.
          • 30912
          • 463 Posts
          Your welcome, it should work as is as it was taken from a directy implementation

          Good Luck