We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1876
    • 835 Posts
    Hi

    I need to reproduce a website. I have a special webpage

    Visitor choose in a dropdown box, the french departement where he live.
    After submit, I need to display informations about the local distributor and a list of customer on several departments

    You can the see an exemple at this url

    My question, do I have to use a snippet or a datagrid widget?

    Aour

      • 22303 MODX Staff
      • 10,725 Posts
      You will most likely need a snippet to handle the decision on what content to grab based on the dropdown selection. It really depends on where this data is coming from, but you could also use a TV with a datagrid widget to transform a result set from a SQL query using the @SELECT data binding technique (see http://modxcms.com/select.html).

      Here’s some sample snippet code to help explain what I mean about the decision:
      $output= '';
      $industryID= isset($_POST['industry_id']) ? $_POST['industry_id'] : 0;
      if ($_POST && $industryID > 0) {
      	// present the data for a specific industry via a chunk, TV, snippet, etc.
      	$output.= '{{industrySelectedContentChunk}}';
      } else {
      	// present content for or redirect to the page to handle when no selection has been made
      	$output.= '{{selectIndustryContentChunk}}';
      }
      return $output;
      


      In this sample, within your industrySelectedContentchunk, you can reference a TV with the datagrid or call another snippet to retrieve the data and output it however you please, or you could just read the data and build the table in the snippet above.

      Hope that helps a little. grin
        • 6726
        • 7,075 Posts
        Jason, I don’t know if it helps Aour, but it sure helps me after only 3 weeks of toying with MODx I realize the potential of widgets and now I begin to understand @bindings...

        I thought these were for developpers and I was starting to worry that I’d have to "php" my way into conditionnals, used that I am with Textpattern to conditionnal tags embedded in templates (no such thing in MODx, is there ?)...

        Thanks for this smiley
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 1876
          • 835 Posts
          Hi

          @davidm : THANK’S. Now, I know that I am not the only one lost in the matrix, seeking the keys Master. The documentation is good but it is not "Modx for dummies". I come from mambo and I have to format my brain. Some "concept" like TV are not documented enough (usage).

          @OpenGeek: If I understand : I do a snippet who call Chunk, TV or another Snippet to build the ouptut.
          all the data are in special table (same database than modx) so I can create a TV with a datagrid.

          Question : in one webpage :

          Can I call 2 different TV ?
          Can I call the same TV more than one time?
          How pass an value to a TV like $industryID? I want to create a binding : @SELECT * FROM modx_mt_distributeur where industryID=$industryID

          Thank’s

          Aour

            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Don’t feel bad, I’m still very hesitantly fumbling my way around TVs and widgets. I have only the haziest ideas of how they work. I do know that they are very powerful, and a good understanding of them will make me a far better and more useful MODx developer!
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: aour at Nov 26, 2005, 02:03 PM

              Some "concept" like TV are not documented enough (usage).
              Agreed, and we are working on expanding and improving the documentation, but I often find them hard to document, especially since even I discover new ways to use the various MODx concepts on a daily basis.

              Quote from: aour at Nov 26, 2005, 02:03 PM

              @OpenGeek: If I understand : I do a snippet who call Chunk, TV or another Snippet to build the ouptut.
              Yes, but again, this is one of many possible approaches. I personally usually do my SQL work using our DBAPI in a snippet and have it produce the output and save it to a placeholder that I can then insert or use anywhere in a page, chunk, TV, another snippet, the template itself, etc., as long as the snippet that generates the placeholder is also contained on the generated page. This gives me maximum flexibility when laying out the pages and total separation of style and content.

              Quote from: aour at Nov 26, 2005, 02:03 PM

              Question : in one webpage :

              Can I call 2 different TV ?
              Can I call the same TV more than one time?
              How pass an value to a TV like $industryID? I want to create a binding : @SELECT * FROM modx_mt_distributeur where industryID=$industryID
              Yes, you can call an many TV’s as you attach to the template the page is assigned, and as long as any PHP code is valid for executing multiple times in the same page, you can call the same TV multiple times.
              As for passing a value to the @SELECT binding, I haven’t tried this actually, and am searching for an answer to the rather common scenario.