[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

redbeed/taggly

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Taggly, a tag cloud generator

Taggly is a modern port of the old CodeIgniter Taggly library by Gavin Vickery. Packaged with a service provider and facade for Laravel, this package is totally framework agnostic and will help you to generate tag clouds just like the cool kids. Note, styling the cloud is up to you!

Usage

First you must add the service provider to to config/app.php under providers

Watson\Taggly\TagglyServiceProvider::class

And under aliases:

'Tag' => 'Watson\Taggly\TagFacade',

Now you must publish the assets:

php artisan vendor:publish

You can specify the connection in the taggly config file.

config/taggly.php

Overview

First, let's look at what makes up a tag in Taggly. A tag is made up of 3 things:

  • the tag name
  • the number of times it occurs, or it's weight
  • the path it should link to (optional)

You can either use an associative array or a Watson\Taggly\Tag object to represent a single tag. Here is how you represent a tag as an associative array:

$tag = array('tag' => 'Laravel', 'count' => 4, 'url' => 'https://www.laravel.com');

Simply passing this array to a new Tag object to use an object instead.

$tag = new Watson\Taggly\Tag($tag);

Once you have a collection of tags, you can pass them to Taggly and generate a cloud.

$taggly = new Watson\Taggly\Taggly;
$taggly->setTags([$tag1, $tag2, ...]);

echo $taggly->cloud();

You can also just pass the tags to the cloud() method, which is great if you're using the facade too.

Tag::cloud($tags);