• I’m moving (back) to WP from ExpressionEngine. All is going smoothly, thus far, except for the tag cloud(s). ExpressionEngine happened to have a pretty powerful module for a tag cloud, and the result of it can be seen over in the sidebar at http://www.leliathomas.com/portfolio. It uses size “steps” in the CSS to dynamically color the tags according to their size / how much content is within them. After several hours of hair-pulling, I’ve yet to see how I can replicate this in WordPress.

    The first thing that needs to be noted is that I needed my tag cloud to spit out tags from only a certain number of categories. That can somewhat be done with TDO Tag Fixes, even if the URLs it produces are less than ideal. (I’ll take what I can get, at this point.) I need this plug-in for things to work, period; so, any other solutions to my problem must work with it.

    I asked a question on the TDO Tag Fixes’ maker’s website, which is relevant. Here’s what I said:

    I see that there is no “stepping” system in place, but instead tag-link-# classes that are related to the tag’s ID. This is really problematic for me, because I need the color of the tag to correlate with its dynamic size, not its static ID.

    Unless I’m making this unnecessarily complicated–it’s been known to happen–there doesn’t seem to be a dynamic way for me to color the tags according to their size.

    Any ideas?

    Cheers,
    Lelia Thomas

Viewing 4 replies - 1 through 4 (of 4 total)
  • Lelia,
    First of all, nice looking site. I can see the “steps” you’re referring to. They are based on groups of classes, a certain range uses a particular color and font size.

    Maybe this all happens behind the scenes in EE. This could be done in WP, but some CSS code may be needed. Here’s a piece of code from one of my sites. Below it I have written a chunk of CSS “re-coloring” code that’s similar to what’s going on in your site. As you can see, it’s set up to have a range be a particular color:

    <a style="font-size: 10px;" title="1 topic" class="tag-link-14" href="http://blahblah.org/index.php/tag/back-pain/">back pain</a>

    .tag-link-14, .tag-link-15, .tag-link-15 {
    color:#65774D;
    }

    The only minor annoyance is that WP seems to generate font-size style tags… convenient in most cases, but tricky to override.

    As far as category stuff goes, I’m not sure about how that would work.

    Hope this helps!
    Dave

    you could edit the plugin code and add those color steps yourself:
    tdotf.php from line 341:

    $a = array();
    
    $color = array ( '336699', '75d175', 'd175d1', '996633', '993366', '669933', '339999' ); // add this list of stepped color codes of your choice ( 0 to 6 = 7 steps )
    
    	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
    
    	foreach ( $counts as $tag => $count ) {
    $col_step = round( 6 * ( $count - $min_count ) / $spread ); // add this 0 to 6 for color array index (edit 6 if you have more stepped color codes)
    		$tag_id = $tag_ids[$tag];
    		$tag_link = clean_url($tag_links[$tag]);
    		$tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag ));
    		$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " .
    			( $smallest + ( ( $count - $min_count ) * $font_step ) )
    			. "$unit; color: #". $color[$col_step] . "'>$tag</a>";  //edit here; add this code (  color: #". $color[$col_step] . " )
    	}

    hope you understand the logic of it;
    you’ll sure find your own harmonious colors to ahow the tags.

    good luck 😉

    Thread Starter leliathomas

    (@leliathomas)

    Hi, flamenco. Thanks for your suggestions! Unfortunately, the classes you’re pointing to in your example (tag-link-14, etc.) are static. By that, I mean they’re actually referring to the tag IDs, not the tags’ font sizes. I thought they were referring to the font sizes at first, too, because that would make sense, but noooo…

    You can see what it does now by visiting my work in progress over at http://www.leliathomas.com/wp/portfolio.

    The code powering the tag cloud:

    <?php if(function_exists('tdotf_cat_tag_cloud')) {
       tdotf_cat_tag_cloud('cat=3,4,5,6');
       } ?>

    The example CSS that’s currently in place:

    #sidebar a.tag-link-20 { color: green;}
    #sidebar a.tag-link-22 { color: purple;}
    #sidebar a.tag-link-36 { color: pink; }
    #sidebar a.tag-link-39 { color: red; }

    So yes, as you can see, the link numbers aren’t according to font-size, but just ID. It’s driving me mad. I have no clue why a developer would think that makes sense. It makes the tag cloud essentially static, when it comes to the CSS. I’d have to edit the ID-oriented tag classes each time one of the tags changed size, due to more content being added to them. WTF? Am I just missing something? I hope so!

    Egads,
    Lelia

    Thread Starter leliathomas

    (@leliathomas)

    Thanks for your suggestion, alchymyth. To be honest, though, I hate editing plug-ins. I’m more of a front-end developer, first off, but secondly, it sort of defeats the purpose of all the easy one-click installs. Honestly, this is a WP problem more than a TDO Tag Fixes problem. I was pretty shocked to find WP didn’t have this built-in!

    Can you think of any way I could get around having to edit the plug-in itself? I can’t, but here’s to hoping.

    Lelia

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Tags in a category and dynamic tag coloring.’ is closed to new replies.