We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1828
    • 137 Posts
    To date I have created ’hard-coded’ lists of categories (or tags) in a TV with a multi-select list output, so that manager users can associate one or more of the categories/tags with each document (typically articles that are summarised by Ditto). However, I would like to enable end users to maintain their own list of categories, without having to edit a TV and use unfamiliar syntax ("Cat1==Cat1||Cat2==Cat2", etc.) Is there a way to achieve this using built-in functionality in MODx or is a snippet to read/write data and an extra db table required?

    Thanks,
    Anton
      • 1828
      • 137 Posts
      Thanks for the suggestion.

      I set this up with the "Input Option Values" field in the category TV bound to a specific document containing a list of categories ("@Document 31"), but there seems to be a problem with the delimiter.

      The category TV is now only displaying the options as a single item - "cat1cat2cat3" etc - on the one line.

      The input type is set to "Check box" (have also tried "List box multi-select").

      The widget is set to "Delimited list".

      I have tried using "\n", "\r\n" and "," as the delimiter. The document feeding the options list has a blank template and no RTE.

      The only way I did get it to work is by changing the syntax to the original "Cat1==Cat1||Cat2==Cat2"...which obviously defeats the point of making this editable by the end user.

      Any further ideas on how to get this working would be appreciated!

        • 1828
        • 137 Posts
        Thanks for the extra info; however, it isn’t 100% functional.

        I now have the category check box options listed correctly under the TV when editing an article. Changes to the options (when editing an article) are saved to the DB, but the changes are not reflected in the TV - i.e., the same (default) category is the only checked option regardless of what is saved in the DB.

        Anton
          • 1828
          • 137 Posts
          I got it working in 096 like so:

          Input field of the TV:
          "@EVAL $doc = $modx->getDocumentObject(’id’, 32); $list = $doc[’content’]; $listTV = str_replace("\r\n", "||", $list); return $listTV;"

          Delimiter: ","

          Thanks for your help!

          Anton

            • 23571
            • 223 Posts
            This looks like a really straightforward, I was able to replicate it easily. Thanks.

            Anton, as you were working with this did you create a method for returning this category list as a list of hyperlinks (for the site visitors to see) too? I am assuming that you were ultimately looking for a method to display member type page listings categorically on a site. If this is so would you care to share your approach on this?

            Thanks, Greg.
              • 4310
              • 2,310 Posts
              Thanks ganeshXL & AntonL smiley
              Nice way of making it easier for the client to update their categories etc.
                • 1828
                • 137 Posts
                Hi Greg,

                This was over a year ago so my memory is a little foggy! Basically, there was list of articles being summarised by Ditto and categorised by the method described above. I used Ditto to display category links sourced from the TV and this enabled site visitors to filter the articles by category - I am pretty sure this part is covered in the Ditto docs or forum somewhere.

                Anton
                  • 23571
                  • 223 Posts
                  Thanks, that’s what I figured. I just wanted to ask before I spent too much time in that direction.