Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Suggestion about most popular tags widget

+1 vote
3,058 views
asked Dec 9, 2015 in Plugins by fara

I think most popular tags widget is really unreadable.

Now it is like this:

 

For example it could be something like this:

These little things could be done easily by css but can make big difference.

What's your idea?

 

Q2A version: 1.7.1

3 Answers

+1 vote
answered Dec 9, 2015 by Gurjyot Singh

I have also raised the same concern about this widget because other than one tag none are easily readable. Then I raised an issue in github, if you can support it there by commenting there then it can surely help in changing the looks of this widget. Here is the link to that issue.

+3 votes
answered Dec 9, 2015 by Scott
If you want tags like your second image you can install my plugin which does exactly that: https://github.com/svivian/q2a-tag-list-widget

The problem with the word cloud plugin is that the tags are sized in proportion to the number of questions. The tag "plugin" has way more questions than any other tag, so it ends up being huge while all the other tags are much smaller. It's not really what I'd call a word cloud because it just orders the words from largest to smallest, with no alignment. You can't really do it properly using basic HTML/CSS.

So I'm not really sure of the best solution. Maybe we could make the sizing optional?
commented Dec 9, 2015 by fara
Thanks Scott,
I didn't know about your plugin, Thanks.
Could you please take a look at my answer to this question? what is your idea?
commented Dec 9, 2015 by Gurjyot Singh
Hello Scott, I would suggest you to ask this question to community that even they want this plugin or if they would like to have Most Popular Tag plugin (designed like normal tags)?
As far as I know about websites, only those things should be used in sidebar which give value to users (talking as a website owner). And Tag cloud widget solves no issue and neither it provide any value to users as it is now.
So reconsider about this plugin and remove if it doesn't fit Q2A, instead use your own  Q2A tag list widget plugin there.
0 votes
answered Dec 9, 2015 by fara
edited Dec 9, 2015 by fara

Here is a solution.

However I really don't know if it works fine or not!

I took a look at codes of Most Popular Tags Widget and I think the problem is with this line:

$size = number_format($maxsize * $count / $maxcount, 1);


I did these changes in my local server like this:

 

public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
    {
        require_once QA_INCLUDE_DIR.'db/selects.php';

        $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags')));

        $maxcount = reset($populartags);

        $themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags')));

        $themeobject->output('<div style="font-size: 10px;">');

        $maxsize = qa_opt('tag_cloud_font_size');
        $minsize = qa_opt('tag_cloud_minimal_font_size');
        $scale = qa_opt('tag_cloud_size_popular');
        $blockwordspreg = qa_get_block_words_preg();

        $x = array();
        foreach($populartags as $tag=>$count){
            array_push($x,$count);
        }

        foreach ($populartags as $tag => $count) {
            $matches = qa_block_words_match_all($tag, $blockwordspreg);
            if (empty($matches)) {
                if ($scale) {

                    $size = (($count - min($x)) / (max($x) - min($x)) * ($maxsize - $minsize)) + $minsize;
                } else
                    $size = $maxsize;

                $themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag)));
            }
        }

        $themeobject->output('</div>');
    }
}


And you can see the differences here:

This image is before changes

 

and this one after changes:



(I used your plugin to show you the counts of each tags)

What do you think?

commented Dec 11, 2015 by fara
Any idea about this?
...