Add Tag Cloud on Home Page

Topics: Controls
Jul 22, 2012 at 5:32 AM

Where and how are tags stored in a BlogEngine blog? How can I list all the tags or make something like Tag Cloud and show it on the Home Page?

Coordinator
Jul 23, 2012 at 3:28 PM

There is a "tag cloud" widget you can use. If you need something custom, look at controls/tagcloud.cs for example on how to get and parse tags. Something like:

foreach (var tag in Post.Posts.Where(post => post.IsVisibleToPublic).SelectMany(post => post.Tags))

Jul 24, 2012 at 5:49 PM

@rtur:

From where I can download the Tag Cloud widget. I searched but didn't find any link.

Coordinator
Jul 24, 2012 at 6:45 PM

When you logged in as admin, if your theme supports widgets you should see a drop-down allowing to add widget to the page. One of the options is a tag cloud. Check for more in the docs or in this post.

Feb 10 at 7:00 PM
Is there a way to show only the tag cloud widget on one page, and show recent posts and recent comments widget on another page?
Feb 11 at 9:54 AM
Not through admin but fairly easy to modify theme.
Say you are using standard theme of BE 3, you could do something like the following.

In site master change
 <aside class="sidebar-wrapper float-right">                    
                    <blog:WidgetZone ID="WidgetZone1" runat="server" ZoneName="be_WIDGET_ZONE" />
                </aside>
To
<aside class="sidebar-wrapper float-right">
                    <% if (Utils.IsCurrentRequestForHomepage) { %>
                        <blog:WidgetZone ID="WidgetZoneTags" runat="server" ZoneName="be_WIDGET_ZONE_Tags" />
                    <% } else { %>
                        <blog:WidgetZone ID="WidgetZone1" runat="server" ZoneName="be_WIDGET_ZONE" />
                    <% } %>
                </aside>
With change made to code you would remove tags from existing widget zone and add them into new zone.
The caveat might be, and that depends on your preferences, that for admin purposes the widgets will no longer appear in one place, meaning you would need to switch to the pages where they are visible to edit. If that bothers you, then you could try something like this.
<aside class="sidebar-wrapper float-right">

                    <% if (Security.IsAuthenticated) { %>

                        <blog:WidgetZone ID="WidgetZoneTags" runat="server" ZoneName="be_WIDGET_ZONE_Tags" />
                        <blog:WidgetZone ID="WidgetZone1" runat="server" ZoneName="be_WIDGET_ZONE" />

                    <% } else { %>

                        <% if (Utils.IsCurrentRequestForHomepage) { %>
                            <blog:WidgetZone ID="WidgetZone2" runat="server" ZoneName="be_WIDGET_ZONE_Tags" />
                        <% } else { %>
                            <blog:WidgetZone ID="WidgetZone3" runat="server" ZoneName="be_WIDGET_ZONE" />
                        <% } %>

                    <% } %>

                    
                </aside>
Feb 20 at 6:48 PM
Thank you for the answer, the widget separation is working. However, I have another problem with the tag cloud. It is not updating when I add new tags to posts. I can see the new tags in the admin page but not in the widget. Is there some known issue regarding this or is there something wrong with my implementation? Thank you in advance.
Feb 22 at 7:57 PM
Just checked that, tags in the widget only update with a refresh i.e. add a space in web.config and save.
Would need to familiarise myself with the new setup to see what's occurring there.