How can I filter tags in the Tag Cloud

May 21, 2009 at 3:45 PM

Ok, this may be a unique situation but here goes.  I am looking for the ability to filter the tags that show up in the Tag Cloud without affecting the tag itself, in other words the tag should not appear in the tag cloud but links to the tag should still work.  My site completely automates posts and places a numeric tag onto each post based upon the numeric id of the automation suite that ran.  Results are posted in a "dashboard" and the dashboard links to the numeric post so that functionality still needs to work.  The problem is that the numeric number does not mean anything to the people using the site, only the actual name of the suite that ran is important (and also tagged) so I do not want to clutter the tag cloud with a bunch of numbers.  I cannot use the actual names for the links in the dashboard b/c there are some differences between the actual names and the displayed names.

Anyway, is there a way of filtering out all Numeric tags before they hit the Tag Cloud?

Thanks for any help.

May 21, 2009 at 4:00 PM

I figured that as soon as I asked for help I would figure it out :)

Anyway, in case anyone else has a similar issue this is the very easy way that I filtered the Tag Cloud, with small modifications you could filter it for something other than numeric values.  This mod was to the "widgets/Tag Cloud/widget.ascx" file.

public override void LoadWidget()
    {
        foreach (string key in WeightedList.Keys )
        {
            if (!IsNumeric(key))
            {
                HtmlGenericControl li = new HtmlGenericControl("li");
                li.InnerHtml = string.Format(LINK, Utils.RelativeWebRoot + "?tag=/" + Utils.RemoveIllegalCharacters(key), WeightedList[key], "Tag: " + key, key);
                ulTags.Controls.Add(li);
            }
        }
    }

    private static bool IsNumeric(object value)
    {
        try
        {
            int i = Convert.ToInt32(value.ToString());
            return true;
        }
        catch (FormatException)
        {
            return false;
        }
    }