Add a tag cloud to the CGBlog module

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

Add a tag cloud to the CGBlog module

Post by scooper »

We have a client using the CGBlog module who wanted to have their various categories display as a tag cloud on their blog.

After a bit of thought we realised we could use 'browse by category' action of the module together with some smarty trickery to do it pretty neatly. Like this:

Create a new 'Browse Category Template' or change your default one to:

Code: Select all


{assign var=maxcount value=0}
{foreach from=$categories item='one'}
	{if $one.count gt $maxcount}{assign var=maxcount value=$one.count}{/if}
{/foreach}

{foreach from=$categories item='one'}
<a href="{$one.url}" title="{$one.name}"  
class="cloud_{math|round equation="(currentCount / maxCount * 10)"  currentCount=$one.count  maxCount=$maxcount}">{$one.name'}</a>
{/foreach}

Add some suitable styles to your stylesheet. Something like this as a start:

Code: Select all


 a.cloud_1 { font-size: 0.7em; line-height: 110%;}
 a.cloud_2 { font-size: 0.8em; line-height: 110%;}
 a.cloud_3 { font-size: 0.9em; line-height: 110%}
 a.cloud_4 { font-size: 1.0em; line-height: 110%;}
 a.cloud_5 { font-size: 1.1em; line-height: 110%;}
 a.cloud_6 { font-size: 1.2em; line-height: 110%;}
 a.cloud_7 { font-size: 1.3em; line-height: 110%;}
 a.cloud_8 { font-size: 1.4em; line-height: 110%;}
 a.cloud_9 { font-size: 1.5em; line-height: 110%;}
 a.cloud_10 { font-size: 1.6em; line-height: 110%;}

and then just use the {CGBlog action="browsecat"} wherever you want your tagcloud. If you've created a new template that's not the default then obviously pass the name of your template like {CGBlog action="browsecat" browsecattemplate="tagcloud"}.

you should end up with something that looks like this:
http://www.runnymedetrust.org/projects-and-publications/appg/parliamentary-blog.html

s.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Add a tag cloud to the CGBlog module

Post by applejack »

Very good but unless you have paid for the licence of CMSMS you should keep the copyright notice in the header code.

Website Design & Production
http://www.applejack.co.uk
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Add a tag cloud to the CGBlog module

Post by jmcgin51 »

applejack wrote: Very good but unless you have paid for the licence of CMSMS you should keep the copyright notice in the header code.
This is appreciated, but not required, unless you're using a module whose license requires it.  The CMSms GPL does not require that you leave the copyright notice in the header code.  It does require that you leave the copyright information in the source files, and I believe it requires that you leave credit in the admin panel.  But on the front end, I believe there is no requirement.

In fact, it can be considered a security risk to leave the copyright notice in the front end, because revealing the CMS name can lead to hacking attempts using known or unknown vulnerabilities.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Add a tag cloud to the CGBlog module

Post by applejack »

Hi jmcgin51

I always thought you had to keep this but I agree that it is a potential security risk. Thanks I stand corrected.

Website Design & Production
http://www.applejack.co.uk
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Add a tag cloud to the CGBlog module

Post by Dr.CSS »

We have a full time staff looking for any vulnerabilities that may arise in CMSMS, so rest assured if anything comes up it is dealt with in a very timely manner, hence no big security thread as seen in other CMS forums, so I wouldn't worry about anyone finding out you run CMSMS on a site...
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Add a tag cloud to the CGBlog module

Post by jmcgin51 »

@Dr. CSS - I agree that CMSms has an excellent security record, and I agree that the dev team is very much on top of security issues.  No arguments there at all.

With that said, the dev team has to be aware of a vulnerability before they can fix it, and awareness often comes only after a successful attack.  I would rather not advertise my system brand in the front end, as it makes a potential attacker's job just that much easier.  (Like having a sign on your house saying "protected by Brand X security system".  Anybody with a motivated brain cell can do the research to find out how to bypass those systems.  Might as well say "door's open, come on in".)

In the backend, I'm proud to promote CMSms!
ofrost
Forum Members
Forum Members
Posts: 47
Joined: Tue May 01, 2007 8:52 pm

Re: Add a tag cloud to the CGBlog module

Post by ofrost »

Code: Select all

{assign var=maxcount value=0}
{foreach from=$categories item='one'}
	{if $one.count gt $maxcount}{assign var=maxcount value=$one.count}{/if}
{/foreach}

{foreach from=$categories item='one'}
<a href="{$one.url}" title="{$one.name}"  
class="cloud_{math|round equation="(currentCount / maxCount * 10)"  currentCount=$one.count  maxCount=$maxcount}">{$one.name}</a>
{/foreach}
Corrected by Peciura. This version works.
Post Reply

Return to “Tips and Tricks”