We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22996
    • 15 Posts
    I am putting together my first MODx site and like what I see with Ditto. I need the ability to retrieve/filter documents based on a person’s webgroup and/or document group. I see that ditto provides the ability to use the document object variables, but I can’t see how you can filter based on document or webgroup.

    Is it best to create a TV on each document that captures the webgroup? I just thought this would be redundant.

    Any help would be great.
      • 7231
      • 4,205 Posts
      Check out the filtering options:
      http://ditto.modxcms.com/tutorials/basic_filtering.html

      I am guessing that you could use the privateweb or privatemgr variable to filter but I did not see how to know the specific document group. Ditto also has the hidePrivate paramenter to allow private documents to be included in the output.

      # privateweb - [0|1] Whether or not this document has been assigned to a private web document group.
      # privatemgr - [0|1] Whether or not this document has been assigned to a private manager document group.

        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 22996
        • 15 Posts
        Thanks for that. I took a deeper look into those items and it appears that is more of a "flag" - meaning, it excludes private documents...all private documents. I guess I am looking more at a specific parameter that can "include" only the documents that pertain to the person’s webgroup (after they are logged in) or document group.

        I see that there is the use of @EVAL available, but do not see any concrete examples of it’s usage.
          • 22996
          • 15 Posts
          Wow. That works fine for me. Thanks so much for the quick response. I think I have the hang of it now (snippet call within the Ditto snippet).
            • 16574
            • 49 Posts
            I get this error

            « MODx Parse Error »
            MODx encountered the following error while attempting to parse the requested resource: 
            « PHP Parse Error » 
              
            PHP error debug 
              Error:  implode() [function.implode]: Bad arguments.   
              Error type/ Nr.:  Warning - 2   
              File:  C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php(769) : eval()'d code   
              Line:  31 


            It seems it doesn’t get any results.
            Anyone know what might be wron?

            It’s a matter of life or death.
              • 33372
              • 1,611 Posts
              The code above is not really error-proof. If no documents are found that matches the web group that you give it, the $docs array is empty and so when you try to implode a non-existent array you get the error that you’re seeing. You’d get a more clear error message if that part of the code were something like:

              	$dbQuery = "SELECT document FROM $tWebGroups WHERE document_group='$wgID' ";
              	$result = mysql_query($dbQuery) or die( mysql_error() );
              	if(mysql_num_rows($result) > 0) {
              		while ($row = mysql_fetch_array($result)) {
              			extract($row);
              			$docs[] = $document;
              		}
              	}
                      else return '
                      ERROR: No documents found!
                      Web Groups: '.$tWebGroups.'
                      Document Group: '.$wgID;
              


              But the root of your problem is that the snippet is not finding any documents that match the web group that you’re asking it to look for, so just changing the error message won’t resolve the situation. Check the parameters you’re feeding to the snippet and make sure they’re correct. If you don’t find the problem, post your snippet call and other info here so we can review it.
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 16574
                • 49 Posts
                thank you very nice.
                It works perfectly.

                You rule. smiley
                  • 10076
                  • 1,024 Posts
                  Could a script like above be used to asign id’s to the excludeDoc or includeDoc parameter in wayfinder using a tv with tags? So retrieving docs on tag value? I tried a little but only get parsing errors. So before spending days the view of an expert would be great.

                  Frank.
                    • 33372
                    • 1,611 Posts
                    Quote from: Frank at May 23, 2008, 03:20 AM

                    Could a script like above be used to asign id’s to the excludeDoc or includeDoc parameter in wayfinder using a tv with tags? So retrieving docs on tag value? I tried a little but only get parsing errors. So before spending days the view of an expert would be great.
                    I may not be understanding what you want to do properly, but Ditto can already filter its results based on tags.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 10076
                      • 1,024 Posts
                      Tried it and get a sql syntax error returned

                      this is the call:
                      [[Wayfinder? &startId=`3` &level=`1` &sortBy=`pagetitle` &sortOrder=`asc` &parentClass=`hide` &parentRowTpl=`cssplay_parentRow` &outerTpl=`cssplay_outer` &innerTpl=`cssplay_inner` &rowTpl=`cssplay_row` &outerClass=`menu` &cssTpl=`cssplay_flyout`&excludeDocs=`[!getTVList? &tv=`itemTags` &str=`Food,Walks`!]`]]


                      the tv is itemTags
                      the tags are Food,Walks,Places,Musea
                      snippet like suggested getTVList

                      error:

                      « MODx Parse Error »
                      MODx encountered the following error while attempting to parse the requested resource: 
                      « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[!getTVList)) AND sc.id IN (25) GROUP BY sc.id ORDER BY sc.pagetitle ASC' at line 1 » 
                            SQL: SELECT DISTINCT sc.id, sc.menutitle, sc.pagetitle, sc.introtext, sc.menuindex, sc.published, sc.hidemenu, sc.parent, sc.isfolder, sc.description, sc.alias, sc.longtitle, sc.type,if(sc.type='reference',sc.content,'') as content, sc.template, sc.link_attributes FROM `pianoquartet`.`site_content` sc LEFT JOIN `pianoquartet`.`document_groups` dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 AND (sc.privateweb=0) AND sc.hidemenu=0 AND (sc.id NOT IN ([!getTVList)) AND sc.id IN (25) GROUP BY sc.id ORDER BY sc.pagetitle ASC ; 
                            [Copy SQL to ClipBoard] 
                        
                      Parser timing 
                        MySQL:  0.0076 s (3 Requests) 
                        PHP:  0.1544 s   
                        Total:  0.1620 s 
                      


                      And this redundant method I am trying, is because I cant seem to find or figure out a way to filter document from the tree to include or exclude them from the menu. Thanks for this script.

                      frank