strategeek (@strategeek)

Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

  • strategeek
    Participant

    @strategeek

    @23creative maybe you can give a clue?

    This works now perfect when starting a new topic.

    But when I edit a topic with e.g. 3 tags, edit screen shows only 1 tag selected. After I save the edited topic, all tags are lost.

    Any ideas where to search for solution?


    strategeek
    Participant

    @strategeek

    FINAL CODE HERE.
    FOR CHECK BOXES.
    (Difference from the upper one: fixed issue with tags with more than 1 word)

    
    function displayTagElements($selectedTags, /* $userRole, */ $task){
       $html= array();
    $tags = get_categories(array('hide_empty' => 0, 'taxonomy' => 'topic-tag'));
    $selectedTagsArray = explode(',', $selectedTags);
    if($userRole != 'bbp_participant' || $task != 'edit') {
        $html[] = "";
        foreach($tags as $tag) {
            $selected = '';
            if (in_array($tag->name, $selectedTagsArray)) {
                $selected = 'checked';
            }
            $html[] = "<input type='checkbox' name='bbp_topic_tags[]'".$selected." value='". $tag->name ."'>". $tag->name ."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        }
    } else {
        $html[] = $selectedTags;
    }
    
    return implode('', $html);

    strategeek
    Participant

    @strategeek

    Here is a working code. Hooray!

    function displayTagElements($selectedTags, /* $userRole, */ $task){
       $html= array();
    $tags = get_categories(array('hide_empty' => 0, 'taxonomy' => 'topic-tag'));
    $selectedTagsArray = explode(',', $selectedTags);
    if($userRole != 'bbp_participant' || $task != 'edit') {
        $html[] = "";
        foreach($tags as $tag) {
            $selected = '';
            if (in_array($tag->name, $selectedTagsArray)) {
                $selected = 'checked';
            }
            $html[] = "<input type='checkbox' name='bbp_topic_tags[]'".$selected." value=". $tag->name .">". $tag->name;
        }
    } else {
        $html[] = $selectedTags;
    }
    return implode('', $html);

    strategeek
    Participant

    @strategeek

    I think that there is also a need to change the surrounding <input></input> tag to <form></form>


    strategeek
    Participant

    @strategeek

    Hi 23creative. Thank you.

    It works quite well. I get checkboxes with existing tags.

    The problem is that when I select some of them and create a new topic, the created topic doesn’t have these tags attached to it. Any ideas where is the problem?


    strategeek
    Participant

    @strategeek


    strategeek
    Participant

    @strategeek

    Is it possible to change the multiple select form into to separate checkboxes?

    I think this line (that was added in fuctions.php) should be rewritten:

    $html[] = '<select class="chzn-select" multiple="multiple" name="bbp_topic_tags[]" id="bbp_topic_tags">';

Viewing 7 replies - 1 through 7 (of 7 total)