5 users online. Create an account or sign in to join them.Users

Search

The Cumulus ensemble uses the following utility to manage font sizes for HTML and Flash text. Play with the $minsize and $maxsize parameters to modify sizes.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="tags">

    <!-- Configure minimum and maximum point sizes for fonts -->
    <xsl:param name="minsize" select="12"/>
    <xsl:param name="maxsize" select="36"/>

    <!-- Size difference in points between each number of topics -->
    <xsl:param name="step" select="4"/>

    <!-- Custom colors for tags and hovers -->
    <xsl:param name="color">
        <xsl:if test="color"><xsl:value-of select="color"/></xsl:if>
    </xsl:param>
    <xsl:param name="hicolor">
        <xsl:if test="hover-color"><xsl:value-of select="hover-color"/></xsl:if>
    </xsl:param>

    <!-- Calculate font size -->
    <xsl:param name="fontsize">
        <xsl:choose>
            <xsl:when test="topics &lt; $minsize div $step"><xsl:value-of select="$minsize"/></xsl:when>
            <xsl:when test="topics &gt; $maxsize div $step"><xsl:value-of select="$maxsize"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="$step * topics"/></xsl:otherwise>
        </xsl:choose>
    </xsl:param>

    <!-- Anchor for each tag -->
    <a href="{uri}" title="{topics} topics" class="tag-link-{@id}" rel="tag" style="font-size: {$fontsize}pt;">
        <xsl:if test="$color != ''">
            <xsl:attribute name="color"><xsl:value-of select="$color"/></xsl:attribute>
        </xsl:if>
        <xsl:if test="$hicolor != ''">
            <xsl:attribute name="hicolor"><xsl:value-of select="$hicolor"/></xsl:attribute>
        </xsl:if>
        <xsl:value-of select="tag"/>
    </a>
</xsl:template>


</xsl:stylesheet>

Great work bauhause! I came up with my own tag cloud template not so long ago, supporting similar functionality (pass a range and it will calculate sizes). One suggestion — I'd be cautious of setting font sizes directly in the XSLT. A preferred method would be to use a set of classes on the anchors so that styling is kept in external CSS files.

Out of interest, what would a uri node look like? For the rel=tag microformat the tag needs to be the last chunk of the URL string. Just wondering, because I'm a microformat nut ;-)

Thanks, nickdunn. I should have taken a look at previous implementations before I created mine. Your XSL looks a lot more elegant at first glance. I believe you are right about setting font sizes in external CSS instead of inline. I first wanted to match the existing functionality of WP-Cumulus so as not to require a more extensive rewrite of the ActionScript. It would be possible to apply a different XSL template, or use a different mode, for rendering the anchors in the HTML so that it is well-formed while maintaining the required format for the XML served to the SWF file.

As a side note, I did try using apply-templates instead of call-template for the tags utility, but even though I was trying to match the entry node, the output include the text value of the section node.

  <xsl:apply-templates match="data/tags/entry"/>

If anyone has any ideas about why that would happen, please let me know.

I need to learn more about microformats. I've only experimented a little with the hCalendar microformat. Moving the rel attribute is an easy fix. Can you explain the usage of the uri node?

Sure. The rel-tag microformat stipulates that the last part of the URL is the tag itself, i.e. after the last forward-slash in the URL.

Therefore for the tag to be a valid microformat, the URL should look along the lines of:

http://domain.com/articles/tags/my-tag

Trailing slashes are ignored.

If that URL structure fits your site, then adding rel=tag to the links is a valid use of the microformat. Simple as that :-)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details