Package Data | |
---|---|
Maintainer Username: | tsiedsma |
Maintainer Contact: | tsiedsma@lithiumhosting.com (Troy Siedsma) |
Package Create Date: | 2016-05-02 |
Package Last Update: | 2020-08-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:21:30 |
Package Statistics | |
---|---|
Total Downloads: | 19,056 |
Monthly Downloads: | 272 |
Daily Downloads: | 6 |
Total Stars: | 7 |
Total Watchers: | 2 |
Total Forks: | 4 |
Total Open Issues: | 3 |
from Lithium Hosting
We're always open to pull requests, feel free to make this your own or help us make it better.
(c) Lithium Hosting, llc
This library is licensed under the GNU GPL license; you can find a full copy of the license itself in the file /LICENSE
A Laravel package that aids in generation of tag clouds
Install this package through Composer. To your composer.json file, add:
"lithiumdev/laravel-tagcloud": "~1.0"
Next, run the Composer update comand
$ composer update
Add the service provider to app/config/app.php, within the providers array.
'providers' => array(
// ...
LithiumDev\TagCloud\ServiceProvider::class,
),
use LithiumDev\TagCloud\TagCloud;
$cloud = new TagCloud();
$cloud->addTag("tag-cloud");
$cloud->addTag("programming");
echo $cloud->render();
Or:
// Assumes use of Facade "TagCloud"
$cloud = \TagCloud::addTags(['tag_1', 'tag_2', 'tag_3']);
echo $cloud->render();
$cloud->addString("This is a tag-cloud script!");
$cloud->addTags(array('laravel', 'laravel-tagcloud','php','github'));
$cloud->setRemoveTag('github');
$cloud->setRemoveTags(array('tag','cloud'));
$cloud->addTag(array('tag' => 'php', 'url' => 'http://www.php.net', 'colour' => 1));
$cloud->addTag(array('tag' => 'ajax', 'url' => 'http://www.php.net', 'colour' => 2));
$cloud->addTag(array('tag' => 'css', 'url' => 'http://www.php.net', 'colour' => 3));
$cloud->setMinLength(3);
$cloud->setLimit(10);
$cloud->setOrder('colour','DESC');
$cloud->setHtmlizeTagFunction(function($tag, $size) use ($baseUrl) {
$link = '<a href="'.$baseUrl.'/'.$tag['url'].'">'.$tag['tag'].'</a>';
return "<span class='tag size{$size} colour-{$tag['colour']}'>{$link}</span> ";
});
echo $cloud->render();
By default, all accented characters will be converted into their non-accented equivalent, this is to circumvent duplicate similar tags in the same cloud, to disable this functionality and display the UTF-8 characters you can do the following:
$tagCloud->setOption('transliterate', false);