I’ve been wrestling with a
modified NewsEditor snippet by alconpez that I couldn’t get to grips with. In the end I wrote a modification of my own with alconpez as inspiration.
The reason for this snippet is that I needed to have a checkbox incorporated in NewsEditor for specifying if a post was special. More than one checkbox can be used though which makes it suitable for tagging or categorization.
Use
- Make a TV for each checkbox needed. Set Type to Check Box, Elements to the snippet name and Template Access to the template you use for the posts.
- In your NewsEditor chunk add [+tags+] where you want the checkboxes to appear.
- Make a new snippet for the modified NewsEditor or update the existing one.
- In the NewsEditor snippet call add a list of the checkbox-tvs you want to use with &tvtags=`tvcategory1,tvcategory2...` Add "tv" in front of the TV name and use commas to separate them.
A small addition to NewsManager is also needed for it to work properly. The code at line 351 should be changed to the following. This ensures that when deleting a post, the corresponding TV values is deleted along with it since they are no longer needed.
if ($deleteid == $resource[$x]['id']) {
$tbltv = $modx->getFullTableName("site_tmplvar_contentvalues");
$modx->db->delete($tbltv, "contentid = $deleteid");
$modx->db->delete($tbl, "id = $deleteid");
nm_clear_cache();
$modx->sendRedirect($modx->makeUrl($postid));
}
I hope this is useful to someone. Any thoughts on this is greatly appreciated.