We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12941
    • 87 Posts
    I have successfully went through the Create TV-Based Chunks tutorial using the checkbox TV.

    However, currently the snippet automatically sorts the chunks in my category in alphabetical order by chunk name. Is it possible to be able to have them list in my own order, perhaps pulling from the description field rather than the chunk name field in either sequential or alphabetical order, but still display the chunk name (not the chunk description, or whatever other method we can use to sort)?

    I’m not much of a programmer, so if this is possible, it would be extremely helpful to know what I should change in order for this functionality to take effect.
      • 21671
      • 244 Posts
      I too am interested in learning how to sort the chunks. My own solution, though dirtier is to have multiple tvs-ie sidebar1(which is the top sidebar chunk), sidebar2(middle sidebar chunk), sidebar3(bottom sidebar chunk)- and have the choices be manually entered versus a dynamic list. Each tv is a listbox single select and then I choose inside the manager which is to appear at the top, which second, and which at the bottom.

      I too am not much of a programmer, but wished there was a way to have the list of available chunks pulled dynamically out of a certain catagory of chunks and then sortable either by dragging or by entering a sort number into some kind of tv field.

      Is this possible and how would one go about it?

      Many Thanks in advance!

      Noah
        • 12941
        • 87 Posts
        Noah, I think we ended up doing the same thing. Dirtier, but I think someone would have to write a snippet or maybe even a plugin to do custom ordering. It would be nice, though.
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          Yes, you can tell the database lookup to sort off of a different column, e.g. name, or description. MySQL doesn’t return data in an arbitrary order, so you’d have to have a column it can sort by.
            • 21671
            • 244 Posts
            Thanks for your answers. I was hoping to be able to manually sort it with a drag and drop type functionality not with an ascending or descending parameter like in a ditto call. I wanted to be able to manually sort the chunks inside the manager. Any ideas?
              • 9207 ☆ A M B ☆
              • 2,475 Posts
              Drag and drop looks nice, and it is a sensible user interface... but programming that sort of functionality is much more difficult than simply using a text field to store a number.

              I’m not up to speed on the available 3rd party plugins... perhaps there’s something existing that you can use to accomplish this, but I’m not aware of it.
                • 4971
                • 964 Posts
                This has been a long time wish that seems nobody has
                been able to accomplish...

                see:
                http://modxcms.com/forums/index.php/topic,901.0.html
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 20413
                  • 2,877 Posts
                  If to sort by chunk description instead...

                  my getChunks
                  <?php
                  $q_chunks = $modx->db->query('
                      SELECT
                          chunk.*
                      FROM '.$modx->getFullTableName('site_htmlsnippets').' AS chunk
                          INNER JOIN '.$modx->getFullTableName('categories').' AS category
                          ON chunk.category = category.id
                      WHERE
                          category.category IN ("'.$category.'") 
                      ORDER BY
                          description DESC
                  ');
                  
                  $ar_chunks = array();
                  while ($row = $modx->db->getRow($q_chunks)) {
                      $ar_chunks[] = $row['name'];
                  }
                  
                  $l_chunks = implode("||",$ar_chunks);
                  return $l_chunks;
                  ?>
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 4172
                    • 5,888 Posts
                    drag-sorting of chunks or also tv-based chunks on the frontend?
                    Can sure be done with bloX/Xedit! (under development, but allready working for me)

                    Will try, if I can make an example for that.

                    Here is an example where we can edit and sort maxigallery-chunks, if we are logged in:
                    http://bruno.tattoocms.de/62.html

                    and how sorting works see here:
                    http://www.siebennull.com/xedit/demo.html
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Quote from: noahlearner at Sep 25, 2009, 09:33 AM

                      Thanks for your answers. I was hoping to be able to manually sort it with a drag and drop type functionality not with an ascending or descending parameter like in a ditto call. I wanted to be able to manually sort the chunks inside the manager. Any ideas?

                      Manual sorting via drag and drop is definitely doable using a plugin. It ultimately stores the array of selected items in a text input, but getting them in there is a bit more cleverly done with some Ajax, creativity and injected HTML.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me