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
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!
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
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
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.
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
Thanks, that’s what I figured. I just wanted to ask before I spent too much time in that direction.