We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9649
    • 33 Posts
    Hi All,
    I have been asked to include in a site that i am doing a ladder of competition results for a football team. So it will need to have about 15 teams listed with their current leadership points for the season but then ordered so that the team winning is listed first.

    I want to make this as easy as possible for the client to do without making a table in the content area that they would swap things around and move things etc. this would be too messy and they would be on the phone to me every 5 minutes to fix it up!!!

    Is there a dynamic way for TV’s to be linked to eachother and then be sorted according to their value?

    ie if team1 has a value of 50 and team2 has a value of 45, team1 would be shown in the first row (tv tags set in the template) and conversely if team1 was 45 and team2 was 50 then the team2 row would move to the first line.

    Due to the small amount of data that needs sorting I don’t think doing it as a Newslisting or ditto would be practical having 15 pages for this one table, I’m sure that someone out there is smarter than I at working this out?!!

    thanks for your help.
      • 727
      • 502 Posts
      I would do this as follows:

      Create a TV called "results" with the type "textarea".
      Tell the user to enter data as follows:

      My Great Team,50
      Uncle Bubba's Team,12
      Big Winners,82


      Then write a snippet to convert this into an ordered HTML table. Hint: split into lines, then split lines using comma, then strip spaces, then sort, then wrap in HTML.

      Andy
        • 9649
        • 33 Posts
        thanks Andy,
        all sounds good if I had any idea what you’re talking about!!!
        I know HOW to use snippets, TV’s, chunks and html but I don’t know how to write a snippet!

        cheers,
        Paul.

        p.s. Uncle Bubba’s Team???!!!!!!!
          • 727
          • 502 Posts
          Hi Paul,

          I hate to say it, and I know you won’t like it, but to customize MODx you will need to learn some PHP. What you want is almost certainly not already written by someone else and made publicly available.

          First take a look at existing snippets (under the resources tab), then start experimenting. For example to start create a snippet called "ResultsTable" and enter:

          <?php
          $output = "<p>Hello World</p>";
          
          return $output
          ?>


          Now edit a page and add:

          [[ResultsTable]]


          You should see your text. Some resources you will likely need:

          http://us3.php.net/manual/en/function.split.php
          http://us3.php.net/manual/en/function.trim.php
          http://us3.php.net/manual/en/function.sort.php

          Also search on the forum here for how to get the value of a template variable. Hope this helps. Good luck!

          Andy
            • 9649
            • 33 Posts
            thanks Andy,
            I should dabble into php a bit more but I’m trying to hang on to the last threads of being a designer before people start calling me a programmer!!!

            You really helped me though - from your idea of sorting a html table I did a bit of a google and found my solution!

            If anyone is reading this thread and looking for the solution (a MODx one would have been ideal!) here it is:
            http://www.frequency-decoder.com/2006/09/16/unobtrusive-table-sort-script-revisited/

            thanks.
              • 7231
              • 4,205 Posts
              You have a few ways of doing this in MODx. 1) the above suggested method, 2) use MODx documents and Ditto to create the table, 3) add a TV for each team and use a snippet to do the sorting (several ways to do this with basic php), 4) custom db table and snippet to display...there are more.

              If the number of teams is small and will not grow using TVs may be a good solution. Are you only storing the final points, or will this be a table with the points history (game 1, game 2,...)

              Anyway, seems that you got it resolved.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]