We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28341
    • 43 Posts
    I’ll probably get an oscar soon for asking all these questions but... there are a couple of more obstacles throughout my project. One of them is the relationship between different posts. I have a couple of products that are displayed, each with their own page. These products all have one or more certificate(s) associated with them. The certificates and the products are stored in entirely different categories, the question is how does one tie them together in a good, easily editable way? WordPress has tags, Drupal has all sorts of associable types but with ModX - what should I use?
      • 33337
      • 3,975 Posts
      Tags.

      Create a new TV, attach it to the template and use this TV as tags. eg. tag1,tag2

      OR you can have preset tags: eg. a dropdown list of predefined tags in TV input options.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 28341
        • 43 Posts
        I would say your later suggestion sounds very efficient, if I can fetch all current ceritificates. I’ll look into it.
          • 33337
          • 3,975 Posts
          Try @SELECT binding for TV input.
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 28341
            • 43 Posts
            OK the ideal solution would be to make a multi-select list at a product where the user can click in one or more certificates tied to that product. The values of the list should be the certificate’s images as well as a link to their respective pages. I have a slight hint of how to do this... and that’s it smiley Could you help me out?
            Guessing a @SELECT-query in the TV to fetch the certificates. How about storing multiple values in that list? Is it even possible?
              • 28341
              • 43 Posts
              Solved:

              1. Create a TV with a Listbox (Multi-Select).
              2. Apply "@SELECT pagetitle,id FROM modx_site_content WHERE parent = X" in the Input Option Values field (X is your Certificates resource).
              3. Apply a Widget with a Delimited List using commas.
              4. In a Template, use Ditto and call the selected associations by using "[!Ditto? &documents=`[*related-certificates*]` &tpl=`certificate-list-item` &noResults=`<p>No certificates related to this product.</p>`!]"

              One thing I don’t understand is how ModX "knows" that I want to display Pagetitle in the listbox (the user would never know which ID belonged to what certificate, obviously) then correctly uses the ID for finding the document in the Ditto output, thereby (with the aid of the "certificate-list-item" template) showing the correct image and link.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                the input processor sees that it’s been handed a resource, so it must be a recordset from a database query. It loops through it just as you would after making a select query, and creates the array necessary for building the input.
                else if(is_resource($v)) {
                    while ($cols = mysql_fetch_row($v)) $a[] = $cols;
                }
                


                Experiment a bit... see what would happen if you had @SELECT id,pagetitle ... instead.
                  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