We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4018
    • 1,131 Posts
    Ok...here’s the goal of a snippet I’m working on. I’ve created an unpublished folder that will store published documents that, in turn, will have a couple of document variables associated with them. The variables in question will be multi-select list boxes for assigning multiple categories to a specific document. Then, on any given page, I want to call a snippet that will look at all the documents in that unpublished folder and print a menu based on what categories have been selected in the document variable. The snippet will basically allow for the passing of a category ID that will be the basis for filtering documents that have the category ID selected in its document variable. Sounds easy enough...but I’m finding it isn’t! I’m assuming that the use of the getDocumentChildrenTVarOutput API call is in question here...but I’m not sure exactly what I’m doing wrong in the use of it. I tried the following code in a new snippet just for testing purposes:

    // get all the children of document id 10
    $result = $etomite-> getDocumentChildrenTVarOutput (3,"id,pagetitle");
    for ($i=0;$i<count($result);$i++) {
    	$returnoutput =. $result[$i]["pagetitle"]. " = " . $result[$i]["id"];
    }
    return $returnoutput;


    But I get the following error when I run a page with the snippet inserted in the page:

    Parse error: parse error in d:\appserv\www\modx\manager\includes\document.parser.class.inc.php(620) : eval()’d code on line 4

    Very strange...I’m lost! Any help would be most appreciated! laugh
      Jeff Whitfield

      "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
      • 19726
      • 239 Posts
      I think =. should be .=
        • 4018
        • 1,131 Posts
        I’ll be damned! Always the simple things, ain’t it! Time to do some more testing...hope it works out! smiley If not...I’ll be back!
          Jeff Whitfield

          "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
          • 4018
          • 1,131 Posts
          Ok...solved my problem! I’ll post my results later and tell you how I did it! Whew! Man...talk about a lot to wrap your brain around! LOL! Anyways...

          I managed to get a way to parse out documents and create a menu with the getDocumentChildrenTVars call. Works great too! I used the ShowChilds snippet as a start point and modified it to use getDocumentChildrenTVars instead of the standard Etomite calls to the API. So, basically, if a user selects a number of categories for a specific document then, when I make a call to my snippet with a specific category as a variable, then the snippet will return only the documents that have that category selected in the document variable. I knew there was likely a simple way to do it! Now then...

          Last little problem...now that I have the rest figured out, I still need a way of grabbing the document variable values for the TV itself. What I want is the Input Option Values themselves for a specific TV’s multi-select list (example: name1==value1||name2==value2||name3==value3). The idea is that I can parse the values and create a menu out of them on a page. I’m thinking that the getTemplateVar option might work...but the problem is that this might go on a page that doesn’t have this template variable attached to the template the page is using. Hmm...any ideas? smiley

            Jeff Whitfield

            "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
            • 8287
            • 12 Posts
            Just came across this thread ... this sounds very similar to the approach I was wanting to use on my site as well. What is the status with your snippet? Does it handle just single level categories or multi-level as well? What is the possibility of getting a copy?

            Your help would be greatly appreciated.

            Thanks,
            Dennis
              • 4018
              • 1,131 Posts
              Oh yeah! Completely forgot about this! LOL! Yeah, I’ll post how I did it with some examples when I get to work. smiley
                Jeff Whitfield

                "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
                • 33372
                • 1,611 Posts
                Did you ever post your examples anywhere? I’d love to see them. I’m doing exactly the same thing now.
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 8287
                  • 12 Posts
                  I thought my need for this snippet had gone away but it has just reared its head again. If you have information or examples on it, I would still like to hear about it.

                  Thanks in advance.
                    • 4018
                    • 1,131 Posts
                    No problem. I’ll go back and look at the code and, if anything else, I’ll create a tutorial on my blog on how to do this. smiley
                      Jeff Whitfield

                      "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
                      • 27
                      • 117 Posts
                      Awesome! This will be of special interest to me at the moment

                      Cheers and thanks Jeff