Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-14819

eztagcloud post sorting support (be able to combine most common and alphabetical sorting)

    XMLWordPrintable

Details

    Description

      Comments with patch:
      http://ez.no/developer/contribs/hacks/eztagclouds_limit

      "Short" (from Peter):
      Let's say I want the 10 most common keywords in my tagcloud, but in alphabetical sorting (otherwise the tagcloud looks dumb, IMHO). That's not possible with the current trunk ezwebin. Either you get the first 10 keywords in alphabetical order, or the 10 most common ones in order of keyword count.

      A ridiculous example:

      Let's assume I have got the following keywords (with respective counts in brackets).

      Anton (2), Berta (1), Caesar (3), Dora (1), Emil (4), Franz (1)

      If I use eztagcloud(limit, 3, sort_by, array(count, false())) (Query A), I get the following result:

      Emil (4), Caesar (3), Anton (2)

      If I use eztagcloud(limit, 3, sort_by, array(keyword, false())) (Query B), I get the following result:

      Anton (2), Berta (1), Caesar (3)

      What I really want, however, is this:

      Anton (2), Caesar (3), Emil (4)

      To get this result, eztagcloud needs to first determine the minimum keyword count resulting from Query A, and then use this value (2 in the example) as an additional HAVING clause for Query B (e.g. 'HAVING keyword_count >= 2'). It can either do that as a separate query or as a subselect - I'm not sure what's more efficient with MySQL. Having a second query is slightly easier to understand in PHP, I guess.

      I've implemented a quick-and-dirty solution for my own blog using two queries, but if you're interested, I could certainly develop that to a proper patch. However, to make it really clean, we would probably have to add a new parameter that makes it clear that while the sort order is alphabetical, the limit is applied in a different way.

      Steps to reproduce
      Index: trunk/packages/ezwebin_extension/ezextension/ezwebin/autoloads/eztagcloud.php
      ===================================================================
      --- trunk/packages/ezwebin_extension/ezextension/ezwebin/autoloads/eztagcloud.php       (revision 3470)
      +++ trunk/packages/ezwebin_extension/ezextension/ezwebin/autoloads/eztagcloud.php       (working copy)
      @@ -127,6 +127,18 @@
                          $tags[$row['keyword']] = $row['keyword_count'];
                      }
      
      +               if ( isset( $params['post_sort_by'] ) )
      +               {
      +                   if ( $params['post_sort_by'] === 'keyword' )
      +                       ksort( $tags, SORT_LOCALE_STRING );
      +                   else if ( $params['post_sort_by'] === 'keyword_reverse' )
      +                       krsort( $tags, SORT_LOCALE_STRING );
      +                   else if ( $params['post_sort_by'] === 'count' )
      +                       asort( $tags, SORT_NUMERIC );
      +                   else if ( $params['post_sort_by'] === 'count_reverse' )
      +                       arsort( $tags, SORT_NUMERIC );
      +               }
      +
                      $maxFontSize = 200;
                      $minFontSize = 100;
      
      

      Attachments

        Activity

          People

            andre1 andre1
            andre1 andre1
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: