Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.0k 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
You could use a Javascript parser or write a small function to take the argument as text() and convert it to HTML() or hide the hover card with a bit of CSS as you were trying to do, with an !important override.
I'll formulate an answer later when I'm on the computer.
by
Thanks for your comment. In fact, I'm not a coder, developer, or tester, I have no background in IT or software field. I learned some basic PHP while doing something with Dokuwiki CMS, and I learned  some CSS....after buying your theme.

I was able to convert Categories HTML description into text by using available functions or some simple PHP tricks. But for the description in the Category list widget, specifically, I don't know how.
by
Can you add an example to your website so I can replicate this problem?
by
Do you want me to add the widget to my website, so you come and see? Or do you want me to explain the codes?
by
This is the function in qa-include/plugins/qa-widget-category-list.php

    public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
    {
        $this->themeobject = $themeobject;

        if (isset($qa_content['navigation']['cat'])) {
            $nav = $qa_content['navigation']['cat'];
        } else {
            $selectspec = qa_db_category_nav_selectspec(null, true, false, true);
            $selectspec['caching'] = array(
                'key' => 'qa_db_category_nav_selectspec:default:full',
                'ttl' => qa_opt('caching_catwidget_time'),
            );
            $navcategories = qa_db_single_select($selectspec);
            $nav = qa_category_navigation($navcategories);
        }

        $this->themeobject->output('<h2>' . qa_lang_html('main/nav_categories') . '</h2>');
        $this->themeobject->set_context('nav_type', 'cat');
        $this->themeobject->nav_list($nav, 'nav-cat', 1);
        $this->themeobject->nav_clear('cat');
        $this->themeobject->clear_context('nav_type');
       

    }
by
These are functions in qa-theme-base.php

    public function set_context($key, $value)
    {
        $this->context[$key] = $value;
    }


    /**
     * Clear some context (used at the end of the appropriate loop).
     * @param $key
     */
    public function clear_context($key)
    {
        unset($this->context[$key]);
    }

    public function nav_list($navigation, $class, $level = null)
    {
        $this->output('<ul class="qa-' . $class . '-list' . (isset($level) ? (' qa-' . $class . '-list-' . $level) : '') . '">');

        $index = 0;

        foreach ($navigation as $key => $navlink) {
            $this->set_context('nav_key', $key);
            $this->set_context('nav_index', $index++);
            $this->nav_item($key, $navlink, $class, $level);
        }

        $this->clear_context('nav_key');
        $this->clear_context('nav_index');

        $this->output('</ul>');
    }

    public function nav_clear($navtype)
    {
        $this->output(
            '<div class="qa-nav-' . $navtype . '-clear">',
            '</div>'
        );
    }

    public function nav_item($key, $navlink, $class, $level = null)
    {
        $suffix = strtr($key, array( // map special character in navigation key
            '$' => '',
            '/' => '-',
        ));

        $this->output('<li class="qa-' . $class . '-item' . (@$navlink['opposite'] ? '-opp' : '') .
            (@$navlink['state'] ? (' qa-' . $class . '-' . $navlink['state']) : '') . ' qa-' . $class . '-' . $suffix . '">');
        $this->nav_link($navlink, $class);

        $subnav = isset($navlink['subnav']) ? $navlink['subnav'] : array();
        if (is_array($subnav) && count($subnav) > 0) {
            $this->nav_list($subnav, $class, 1 + $level);
        }

        $this->output('</li>');
    }

    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="' . $navlink['popup'] . '"') : '') .
                (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="' . $navlink['popup'] . '"') : '') .
                '>' . $navlink['label'] . '</span>'
            );
        }

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

 

...