We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29883
    • 15 Posts
    Thanks to MODx I just could make my very first db_query in my life. I just put

    @SELECT pagetitle FROM modx_site_content sc LIMIT 100

    in a TV. Works like a charm. What I’m now looking for is a way to select only the pagetitles in a given parent document. How could I do this?

    Thank you for help.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use Ditto or Wayfinder. Either one lets you use your own templates to display the results; they don’t need to be links and can use just about any document field.
        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
        • 29883
        • 15 Posts
        Thank you, Sottwell, this would be the right way to display the filtered pagestitles in a document. But what I would like is another thing. I will try to explain it better.

        Let’s asume I have a structure like this:

        -products
        --product1
        --product2
        -stores
        --store1
        --store2

        When I write a new document about a new product, I want to have a drop down list with the "store1,store2,..." in it, because any product is sold by only one store (well, it is like communism wink. But using the first mentioned TV would show "store1,store2,product1,product2..."

        I hope I have explained my idea a little bit better?
          • 26178
          • 32 Posts
          Try something like this: @SELECT pagetitle FROM site_content WHERE parent=id_of_a_stores_folder
            • 29883
            • 15 Posts
            Sara, this seems to a good advice. Unfortunatally WHERE = parent_id doesn’t work for me.

            I found at the forum something like this WHERE = {$_REQUEST[’pid’]}") and tried this too with no luck.

            Nevertheless, now I’ve an idea what I’m looking for.
              • 26178
              • 32 Posts
              But do you really need something like {$_REQUEST[’pid’]}? I mean, you have just one stores folder, don’t you? Only thing you need, is its id number, isn’t it? There is another way you can achieve what you want - if your stores documents are all of the same template you can try something like this: @SELECT pagetitle FROM site_content WHERE template=id_of_a_store_template.
                • 29883
                • 15 Posts
                Maybe not. And maybe something went wrong when I tried this WHERE=parent_id-stuff, Sara. I Will give it another try this evening because I now must go to work.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It’s not "parent_id" in the database, the fieldname is "parent".

                  @SELECT pagetitle FROM modx_site_content WHERE parent=5


                  if the container/folder document is #5, and your table prefix is modx_.
                    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
                    • 18830
                    • 161 Posts
                    Thank you both, Sara and Sottwell. It works fine. I used the wrong ID rolleyes