We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15914
    • 145 Posts
    I’m trying to build a table with two columns: Title and Description. I want to display [*longtitle*] in one column, and [*description*] in the other of all the child documents in that folder. I also want both to act as links to the document they relate to.

    Am I wrong in trying to use the DataGrid TV Widget?
      Kunal Kapoor
      Technical Director
      Limesharp Internet Limited - Effective, Functional, Standards Compliant

      IRC Nick: KingKoopa
      Skype ID: KingKoopa16
      • 32241
      • 1,495 Posts
      Can’t you use Newslisting snippet for this?
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 15914
        • 145 Posts
        I suppose with some modification... I just had a complete mental block. Thanks Wendy.
          Kunal Kapoor
          Technical Director
          Limesharp Internet Limited - Effective, Functional, Standards Compliant

          IRC Nick: KingKoopa
          Skype ID: KingKoopa16
          • 15914
          • 145 Posts
          DropMenu was a little too heavy for what I needed it to do. So I came up with this:

          $children = $modx->getDocumentChildren($id=$modx->documentObject['id']);
          
          if (!empty($children)) {
            $output = "<table><caption>" . $modx->documentObject['longtitle'] . "</caption>\n";
            $output .= "<tr><th scope=\"col\">Title</th><th scope=\"col\">Description</th></tr>\n";
            foreach($children as $child) {
              $output .= "<tr><td><a href=\"[~" . $child['id'] . "~]\"> " . $child['longtitle'] . "</a></td>\n";
              $output .= "<td><a href=\"[~" . $child['id'] . "~]\"> " . $child['description'] . "</a></td></tr>\n";
            }
            $output .= "</table>";
            return $output;
          }


          It’ll do nicely.
            Kunal Kapoor
            Technical Director
            Limesharp Internet Limited - Effective, Functional, Standards Compliant

            IRC Nick: KingKoopa
            Skype ID: KingKoopa16
            • 32241
            • 1,495 Posts
            I still don’t really get it though, you can use newslisting and use chunk template to generate the desired table output that you want. In fact you can event fetch all the child documents under the subfolders of your parent folder as well (confusing isn’t it wink).
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 15914
              • 145 Posts
              The situation has gotten a lot more complex! grin

              I don’t want the links in the table on each page to be clickable neither. So I set up a TV which allows me to ask the user a simple Radio Yes||No question, and display the links if neccessary.

              $children = $modx->getDocumentChildren($id=$modx->documentObject['id']);
              $productaslink = $modx->getTemplateVar($idname='ProductListLink');
              
              if (!empty($children)) {
              
                $output = "<table><caption>" . $modx->documentObject['longtitle'] . "</caption>\n";
                $output .= "<tr><th scope=\"col\">Model</th><th scope=\"col\">Description</th></tr>\n";
              
                foreach($children as $child) {
              
                  if ($productaslink['value'] == "Yes") {
              
                    $output .= "<tr><td><a href=\"[~" . $child['id'] . "~]\"> " . $child['longtitle'] . "</a></td>\n";
                    $output .= "<td><a href=\"[~" . $child['id'] . "~]\"> " . $child['description'] . "</a></td></tr>\n";
              
                  } else if ($productaslink['value'] == "No") {
              
                    $output .= "<tr><td>" . $child['longtitle'] . "</td>\n";
                    $output .= "<td>" . $child['description'] . "</td></tr>\n";
              
                  }
              
                }
              
                $output .= "</table>";
                return $output;
              
              }


              I don’t think that would be possible in NewsListing? I also want to be able to change the title of the columns using TVs as the generated table will represent different items, but the structure will still remain the same. I love this MODx, many solutions to one problem thing! Better than having none at all...

              Quote from: Djamoer at Feb 16, 2006, 10:45 AM

              (confusing isn’t it wink).

              You’re right Wendy, it IS confusing.
                Kunal Kapoor
                Technical Director
                Limesharp Internet Limited - Effective, Functional, Standards Compliant

                IRC Nick: KingKoopa
                Skype ID: KingKoopa16
                • 32241
                • 1,495 Posts
                Quote from: Kunal at Feb 16, 2006, 10:53 AM

                I love this MODx, many solutions to one problem thing! Better than having none at all...

                TRUE, but sometime too many solution to one problem is confusing as well. lol wink
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                  • 18397
                  • 3,250 Posts
                  ALL of this is completely possible in NewsListing.

                  You just need to do the following.

                  start table code here
                  [NewsListing? &tpl=`tablerowchunkname` ......other paramaters...]]
                  end table code
                  


                  Then NewsListing will make your table for you. For your yes/no checkbox take a look at the filter parameter (introduced in the new version available on the forums [6.x.x])
                    • 15914
                    • 145 Posts
                    Ahhhh... I need to learn that filter thingymabob. Thanks a lot Mark.
                      Kunal Kapoor
                      Technical Director
                      Limesharp Internet Limited - Effective, Functional, Standards Compliant

                      IRC Nick: KingKoopa
                      Skype ID: KingKoopa16