Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
233 views
in Q2A Core by
closed by

By default, the Category list widget which is bundled with Q2A core displays a list of categories in side panel. 

When you hover over the categories' names, it will show the description of those categories.

However, if your description is HTML rather than mere text, then it will show HTML tags like <a href> <br/> <ul><p>....

It's funny that Q2A core does not have an independent function for this, but instead it is spanned over four or five functions, namely

  • set_context('nav_type', 'cat');
  • nav_list($nav, 'nav-cat', 1);
  • nav_clear('cat');
  • clear_context('nav_type');

Now I want to simply remove that funky hover feature but it cannot be done properly.

I never get an answer since I first posted questions here!!!

Q2A version: 1.8.3
closed with the note: Found the solution myself!
by
edited by
If I create a plugin to override those functions, for example to remove [  title="' . $navlink['popup'] ."  ], it creates a double value, instead of override. Or, maybe I did something wrong.

class qa_html_theme extends qa_html_theme_base

{

    public function nav_link($navlink, $class)
    {
        if (isset($navlink['url'])) {
            $this->output(
                '<a href="' . $navlink['url'] . '" class="qa-' . $class . '-link' .
                (@$navlink['selected'] ? (' qa-' . $class . '-selected') : '') .
                (@$navlink['favorited'] ? (' qa-' . $class . '-favorited') : '') .
                '"' . (strlen(@$navlink['popup']) ? (' title="Hello World"') : '') .
                (isset($navlink['target']) ? (' target="' . $navlink['target'] . '"') : '') . '>' . $navlink['label'] .
                '</a>'
            );
        } else {
            $this->output(
                '<span class="qa-' . $class . '-nolink' . (@$navlink['selected'] ? (' qa-' . $class . '-selected') : '') .
                (@$navlink['favorited'] ? (' qa-' . $class . '-favorited') : '') . '"' .
                (strlen(@$navlink['popup']) ? (' title="Hello Word!"') : '') .
                '>' . $navlink['label'] . '</span>'
            );
        }

        if (strlen(@$navlink['note']))
            $this->output('<span class="qa-' . $class . '-note">' . $navlink['note'] . '</span>');
    }

qa_html_theme_base::nav_link($navlink, $class);

}
by
What I mean by "double values":

CATEGORY NAME #1 (32 )
CATEGORY NAME #1 (32 )
--------------------------------------
CATEGORY NAME #2 (12 )
CATEGORY NAME #2 (12 )
--------------------------------------
CATEGORY NAME #3 (51 )
CATEGORY NAME #3 (51 )
--------------------------------------
CATEGORY NAME #4 (77 )
CATEGORY NAME #4 (77 )
by
edited by
Sorry for the delay. Yes, add the widget to your website so I can see what's happening.
by
+1
Oh, I found a solution myself again.

2 Answers

–1 vote
by
edited by

That's how my search appears

The list of categories looks the same.

On the site itself, it looks like this

And so it looks in the donut topic

I don’t know what is the reason for this display, but all the code was written initially crookedly, which is probably why the developers abandoned it and don’t want to redo it, all the errors got out over time.

by
edited by
The list of categories in yourQ2Asite.com/categories can be modified in the file
qa-include/pages/categories.php

I added some strip_tags like this:
        if (strlen($category['content']))
//            $navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
    $navigation[$key]['note'] .= '  ' . substr(strip_tags($category['content']),0,200).'...';
        if (isset($navlink['subnav']))
            qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap);
    }
}

For the category description when you ask a question. It can be modified in  the file qa-include/ajax/category.php

I added some strip_tags like this:

$shortsring = strip_tags(strtr(@$fullcategory['content'], "\r\n", '  '));
$pos=strpos($shortsring, ' ', 200);
echo  substr($shortsring,0,$pos).'...';


But the list of categories in the side panel is coded in the file
qa-include/plugins/qa-widget-category-list.php

This file calls 4 or 5 functions in qa-theme-base.php.

I tried to override but failed. The problem is nav_list function, (and maybe other child functions) can affect the site nagivation list as well as the list in the admin tool.
–1 vote
by

Here's my solution.

Modify your qa-theme.php or create a plugin to override with this function.

     public function nav_link($navlink, $class)
    {
  unset($navlink['popup']);
  
qa_html_theme_base::nav_link($navlink, $class);
    }

 

...