We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Briggsy, have you got the snippet call cached? If so, try calling it uncached: [! ... !]

    You’ll need to do that for the $_GET parameters to be utilised.
      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 32982
      • 674 Posts
      any link of this snippet/class working?
        Jabiertxof (formerly XYZVISUAL)
        My bussines: http://marker.es
        https://www.youtube.com/user/jabiertxof/videos
      • Quote from: xyzvisual at Sep 04, 2006, 05:27 PM

        any link of this snippet/class working?
        Unfortunately, I do not have any publically accessible instances that I can think of, though I’ve certainly used this class on a dozen or so projects to produce a wide range of table layouts for managing custom data for the respective sites. The snippet was simply an example I threw together to show how to use some of the class.

        I would document more of the features of this, but I am currently producing a replacement for MakeTable that can use chunks as templates, support groupings with custom templates and more. It’s part of the xPDO project I’ve been working on for the past few months, which currently includeds an updated version of MakeTable that works with any xPDO-generated classes (but that’s a whole other topic).

        In the meantime, I’ll answer any questions you might have about the class, or how to author a snippet for it as I am able.
          • 32982
          • 674 Posts
          thanks is only to have an idea of what this clas snippet coul do for me, whithout make a inmersive intro,
          now only want have some time to surf this alone
          hi
            Jabiertxof (formerly XYZVISUAL)
            My bussines: http://marker.es
            https://www.youtube.com/user/jabiertxof/videos
            • 4095
            • 372 Posts
            Thanks Garry, that sorted it out. The Repository shows it as [[MyTableSnippet]] so I never thought of changing it, note to self: check the basics first smiley

            Jarrod Jason, my comment was not to say anything bad about you or your snippet, I was merely thinking it could have been beneficial for us non developer types, however sounds like this is already in hand with your new version which I am looking forward too.

            I do however have one more issue I am hoping someone can help me with?

            I am trying to have it sort by the following headings: Code / Start Date / End Date / Course / Location

            All works except the date fields (which are in dd/mm/yy). Sorting by ascending order I get results below, which is sorting on the first two didgets, and then secondary sort on the second two digits rather than by the actual date as required.

            02/12/06
            03/10/06
            03/12/06
            04/11/06
            04/12/06

              [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
              Admin Sandbox Login: sandbox Password: castle
            • Quote from: Briggsy at Sep 06, 2006, 09:06 PM

              All works except the date fields (which are in dd/mm/yy). Sorting by ascending order I get results below, which is sorting on the first two didgets, and then secondary sort on the second two digits.

              02/12/06
              03/10/06
              03/12/06
              04/11/06
              04/12/06

              It’s Jason BTW, not Jarrod -- but anyway smiley I didn’t take offense to anything you mentioned; was just trying to clarify where my efforts were focused...

              And you should be sorting on the actual field with the date value, which I hope is stored as a DATE type in the database (in the format YYYY-MM-DD); otherwise, you’re going to have to come up with a fancy, custom algorithm to sort that properly after you build the array, or a fancy custom SORT BY clause in your query using MySQL date functions.
                • 7923
                • 4,213 Posts
                If I go to page 2 in the courses table when 25 items are listed per page and then select 50 to be listed, I get "no industries found" message.


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 4095
                  • 372 Posts
                  Quote from: OpenGeek at Sep 06, 2006, 09:33 PM

                  And you should be sorting on the actual field with the date value, which I hope is stored as a DATE type in the database (in the format YYYY-MM-DD);

                  In the example below it is in VARCHAR because DATE turned it into YYYY-MM-DD. The CSV that I used to upload the data was it in DD-MM-YY which is also the same format as I wanted it shown on the site.

                  I can get the CSV changed but still need to show it in DD-MM-YY on website. FOund a few SQL querys and PH codes to do it but couldn’t get them to work (don’t know enough)
                    [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
                    Admin Sandbox Login: sandbox Password: castle
                  • Quote from: Briggsy at Sep 11, 2006, 05:57 AM

                    In the example below it is in VARCHAR because DATE turned it into YYYY-MM-DD. The CSV that I used to upload the data was it in DD-MM-YY which is also the same format as I wanted it shown on the site.

                    I can get the CSV changed but still need to show it in DD-MM-YY on website. FOund a few SQL querys and PH codes to do it but couldn’t get them to work (don’t know enough)

                    Two approaches to sorting properly and displaying any format...

                    1. Store as unix timstamp or datetime in MySQL; MakeTable can then sort by the actual field name and you can use something like this to convert the output when assigning the column values to each row of the result set array:
                    <?php
                    ...
                        'StartDate' => strftime('%d-%m-%y', strtotime($row['Start']),
                    ...
                    ?>

                    and then when creating the table headers:
                    <?php
                    ...
                    'StartDate'=> $objTable->prepareOrderByLink('Start', 'Start Date'),
                    ...
                    ?>


                    The first param in prepareOrderByLink is the actual column name to sort by, and the second is the label for the table header column.

                    2. Without changing the db, you can use strtotime to convert that European date format to a unix timestamp (as in the above example) and make that concatenated with the id field, the key of each array element; you can then simply krsort() the results to order them properly:

                    <?php
                    ...
                    $results= array ();
                    // loop through result of query and assign each row of values
                    foreach ($rs as $row) {
                        // create a sortable key in format {Start}-{Code}
                        $rowKey= strtotime($row['Start']) . '-' . $row['Code'];
                        $results[$rowKey]= array (
                            'Code' => $row['Code'],
                            ...
                        );
                    }
                    ...
                    // Order array in reverse by key
                    krsort($results);
                    ...
                    ?>
                      • 4095
                      • 372 Posts
                      Thanks for your help, it is now working well.

                      I have one last question for you, is there an easy way to have the results so that if the "start date" is todays date or before, then do not return that row in the array (webpage)

                      Then I could just upload the file and the snippet would ensure only current results are returned and I would not need to edit the table all the time to remove old dates.


                      FIXED:
                      $sql = 'SELECT * FROM modx_courses WHERE end >= CURDATE() '.$objTable->handleSorting().' '.$objTable->handlePaging();

                      end is the name of the field in the table modx_courses I wanted to compare dates with (its the end date of the course)
                        [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
                        Admin Sandbox Login: sandbox Password: castle