Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.5k views
in Plugins by

A weird issue, I thought it would be easy to do this:

        function doctype() {
            // remove "frenchfries" from suggested tags
            if($this->template=='ask' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
                $suggesttags = $this->content['script_var']['qa_tags_complete'];
                $suggesttags = str_replace('frenchfries', '', $suggesttags);                
                $this->content['script_var']['qa_tags_complete'] = $suggesttags;
            }
            // default call
            qa_html_theme_base::doctype();
        }
 

The qa_tags_complete get modified, but frontend the tags are still the same!

It seems that the tags are processed before the advanced theme, so changing the field happens after they have been set.

1 Answer

0 votes
by
Yes at the moment those JavaScript lines are all put into $this->content['script'] as an array, in the function qa_output_content in qa-page.php. This is something that I hope to improve in the future.

Potentially you could check that array using a regex.

One better potential solution for now would be to output some JS later on in the page that modifies the qa_tags_complete variable.
by
Yes, solved it using page.js and adding this javascript/jquery:

    if ($("#tags").length > 0){
        // remove words from suggested example tags
        qa_tags_complete = qa_tags_complete.replace('unwanted-word,','');
    }
...