Page 1 of 1

Add a tag cloud to the CGBlog module

Posted: Wed Apr 28, 2010 3:03 pm
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.

Re: Add a tag cloud to the CGBlog module

Posted: Fri Apr 30, 2010 12:15 am
by applejack
Very good but unless you have paid for the licence of CMSMS you should keep the copyright notice in the header code.

Re: Add a tag cloud to the CGBlog module

Posted: Fri Apr 30, 2010 1:09 am
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.

Re: Add a tag cloud to the CGBlog module

Posted: Fri Apr 30, 2010 10:05 am
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.

Re: Add a tag cloud to the CGBlog module

Posted: Fri Apr 30, 2010 10:18 pm
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...

Re: Add a tag cloud to the CGBlog module

Posted: Sat May 01, 2010 1:07 am
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!

Re: Add a tag cloud to the CGBlog module

Posted: Thu Jul 08, 2010 11:59 am
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.