This widget encapsulates the jQCloud plugin for jQuery for drawing neat word clouds that actually look like clouds.
The jQuery plugin producing pure HTML word clouds, that can be easily styled through CSS.
The clouds give greater prominence to words that appear more frequently in the source text.
Requirements ¶
Yii 1.1.6 or above...
Usage ¶
- extract the file under .../protected/extensions
- put in a view a code blocks like the following...
<h1>jCloud Example</h1>
<?php $this->widget('ext.jcloud.JCloud', array(
'id'=>'my_favorite_latin_words',
'htmlOptions'=>array('style'=>'width: 650px; height: 350px; border: 1px solid #ccc;'),
'wordList'=>array(
array(
'text'=> "Lorem",
'weight'=> 13,
'url'=> "https://github.com/DukeLeNoir/jQCloud"
),
array(
'text'=> "Ipsum",
'weight'=> 10.5,
'url'=> "http://jquery.com/" ,
'title'=> "jQuery"
),
array(
'text'=> "Dolor Script",
'weight'=> 9.4,
'url'=> "javascript:alert('JavaScript in URL is OK!');"
),
array(
'text'=> "Sit",
'weight'=> 8,
),
array(
'text'=> "Amet",
'weight'=> 6.2,
),
array(
'text'=> "Consectetur",
'weight'=> 5,
),
array(
'text'=> "Adipiscing",
'weight'=> 5,
'url'=> ""
),
array(
'text'=> "Elit",
'weight'=> 5,
'url'=> ""
),
array(
'text'=> "Nam et",
'weight'=> 13,
),
array(
'text'=> "Yii-extension",
'weight'=> 8,
'url'=> "http://www.yiiframework.com/extensions/"
),
array(
'text'=> "Leo",
'weight'=> 4,
),
array(
'text'=> "Homo Sapiens",
'weight'=> 7,
),
array(
'text'=> "Pellentesque",
'weight'=> 3,
'url'=> ""
),
array(
'text'=> "at molestie",
'weight'=> 1,
),
)
)); ?><!-- cloud -->
Change log ¶
Version 1.0 ¶
- initial release
Version 1.1 ¶
- update of the jQuery plugin (version 0.2.4) / stylesheet
nice
Very nice extension.
I had a problem when changing width to 800px, the center of the cloud was wrong, but i've downloaded new version 0.1.8, updated line 66 of JCloud.php to import the new version and it's fixed!
Please update this!
Thanks
how?
How is this different than just using the jQuery plugin? Any benefits?
closing container
Hi,
maybe it's worth to close the opening html tag of the container by appending a CHtml::closeTag($this->tagName) at the last line of your class.
benefits
@doughty Benefits of using an extension is generally that you just have one folder where all resides and have just one line in your code, where you implement it. If you do this without an extension you have the css and js file in separate directories mixed with your other stuff. You will need to call clientscript at the top of your template to include the css and js. And you need to create the div and call the javascript for adding the cloud.
On the other hand the downside of an extension is the code quality of others might not be so good and you lose some flexibility if you need to do uncommon stuff.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.