Most Popular Tags [Deleted]

That's what I've been trying to tell you all along. :unsure:
Ok, sorry. My bad :(
Maybe I misunderstood your post.

To avoid more misunderstandings:
you would like to have different font sizes although all tags have the same use_count ?
If so, the if ($min == $max) part could be changed to a more randomized part (rand(1,7); )
 
For anybody interested, the code below is where I ended up with it so far. I liked the idea by @pecadm of sorting the weights of the tags within the limited query results but also wanted to cache the results so the query doesn't get run on every page form home page view.

Math is *not* my strong point at all so if anybody spots a problem with my math logic please let me know. :P

Code:
<?php

class Eagle_MostPopularTags_Model_MostPopularTags extends Xenforo_Model_User
{
        public static function MostPopularTagsArray()
        {
                $db = XenForo_Application::get('db');
                $MostPopularTags = array();
                $options = XenForo_Application::get('options');
                $limitforpopulartags = XenForo_Application::get('options')->MostPopularTagsCount;
                $levels = 7;  // How many CSS weights are defined?
                $cacheId = 'Eagle_MostPopularTags';

                if (XenForo_Application::get('options')->MostPopularTagsEnableAddon)
                {

                        // Are there any results in the cache?
                        if($cacheObject = XenForo_Application::getCache())
                        {
                                if($MostPopularTags = $cacheObject->load($cacheId))
                                {
                                        return $MostPopularTags;
                                }
                        }

                        $MostPopularTagsArray = $db->fetchAll($db->limit("
                                SELECT tag, tag_id, tag_url, use_count
                                FROM xf_tag as tag
                                WHERE tag_id
                                ORDER BY use_count DESC", $limitforpopulartags)
                        );

                        // Sort the results
                        sort($MostPopularTagsArray);

                        // Get the highest use count so we can give tag weights within the results
                        $uses = XenForo_Application::arrayColumn($MostPopularTagsArray, 'use_count');
                        $max = max($uses);

                        foreach($MostPopularTagsArray as $tag)
                        {
                                $hrefx = XenForo_Link::buildPublicLink('tags', $tag);
                                $tag['use_count'] = floor(($tag['use_count'] * 100) / floor(($max * 100) / $levels));
                                $MostPopularTags[] = array("tags" => $tag['use_count'], "tag_url" => $tag['tag_url'], "title" => $tag['tag'], "href" => $hrefx);
                        }

                        // Save the results to the cache
                        if($cacheObject = XenForo_Application::getCache())
                        {
                                $cacheObject->save($MostPopularTags, $cacheId, array(), 3600);
                        }

                        return $MostPopularTags;

                }
        }
}
 
What's the criteria for 'most popular'?
Number of threads with each tag, most views per tag?
 
Glitch: When a thread is "unapproved" with its tags and only that thread has these tags, they are not shown in the tag search results (which is correct) but are still shown in the "most popular tags" widget (incorrect).
 
I like the tag cloud a lot but is it possible to remove the orange box upon hover?

Screenshot_18-40-42.png
 
Is the criteria for most popular tags the number of threads the tag is associated with or the number of times a user clicks on a tag?

I have some tags on the cloud that in my AdminCP have a count of 1 and other tags with a higher number are nowhere to be found in the cloud.

Though I must admit it can be tricky looking at the animated tags and probably easy to miss what you're looking for.
 
Server Error ..@Eagle Can you help me

min(): Array must contain at least one element

XenForo_Application::handlePhpError()
min() in Eagle/MostPopularTags/Model/MostPopularTags.php at line 23
Eagle_MostPopularTags_Model_MostPopularTags->getListMostPopularTags() in Eagle/MostPopularTags/ControllerPublic/Tags.php at line 13
Eagle_MostPopularTags_ControllerPublic_Tags->actionIndex() in XenForo/FrontController.php at line 351
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in /home/public_html/index.php at line 13
 
Unfortunately, with the latest upgrade I still have the wrong interpretation of tag classes. For example, in the XF tag search tags are displayed as ".tagCloudTag1" but they are shown in the Most Popular Tags widget as ".tagCloudTag3".
 
Unfortunately, with the latest upgrade I still have the wrong interpretation of tag classes. For example, in the XF tag search tags are displayed as ".tagCloudTag1" but they are shown in the Most Popular Tags widget as ".tagCloudTag3".
Unless you only have 25 tags total on your site then the tag weights are likely correct. The weights are within the 25 tags being shown in the widget subset, not within all of the tags including the ones not being shown. That is unlike the tag search page where it shows all of your tags and the weights are based on all tags, not just a subset.
 
@Eagle

Thanks for this add-on.
Forum down after installing your add-on.

Error message => Zend_Db_Statement_Mysqli_Exception: Mysqli prepare error: Table 'betclever_prod.xf_tag' doesn't exist - library/Zend/Db/Statement/Mysqli.php:77

Xenforo version => 1.44 (Need to upgrade, I know but I'm using a custom theme and waiting the developper).
Did you find the issue?
I have the same problem.
 
Top Bottom