PHP code example of justinvoelker / yii2-tagging

1. Go to this page and download the library: Download justinvoelker/yii2-tagging library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

justinvoelker / yii2-tagging example snippets


$query = new TaggingQuery;
$tags = $query
    ->select('tags')
    ->from('posts')
    ->getTags();

echo TaggingWidget::widget([
    'items' => $tags,
]);

$query = new TaggingQuery;

$tagsA = $query
    ->select('tags')
    ->from('posts')
    ->displaySort(['name' => SORT_ASC])
    ->getTags();
echo TaggingWidget::widget([
    'items' => $tagsA,
    'format' => 'cloud',

$tagsB = $query
    ->items($tagsA)
    ->displaySort(['freq' => SORT_DESC])
    ->getTags();
echo TaggingWidget::widget([
    'items' => $tagsB,
    'format' => 'list',
]);

$query = new TaggingQuery;
$tags = $query
    // used to refine an existing list
    //->items($existingTaggingQueryResults)
    // field that contains the desired tags
    ->select('tags')
    // table to select from
    ->from('post')
    // delimiter (default: `,` (comma))
    ->delimiter(',')
    // number of tags to display (omit for all tags)
    ->limit(50)
    // order used when a limit is being applied
    ->limitSort(['freq' => SORT_DESC, 'name' => SORT_ASC])
    // order of the resulting list
    ->displaysort(['name' => SORT_ASC])
    // array of tags to be excluded
    ->exclude(['junk'])
    // array of tags to be 

echo TaggingWidget::widget([
    // TaggingQuery results
    'items' => $tags,
    // smallest tag size (default: 14)
    'smallest' => '14',
    // largest tag size (default: 22)
    'largest' => '22',
    // unit for tag sizes (default: px)
    'unit' => 'px',
    // display format of 'cloud', 'ul', or 'ol' (default: cloud)
    'format' => 'cloud',
    // url for links (omit for no link)
    'url' => ['post/index'],
    // parameter to be appended to url with tag
    'urlParam' => 'tag',
    // options applied to the list
    'ulOptions' => ['style' => 'text-align:justify'],
    // options applied to the list item
    'liOptions' => [],
    // options applied to the link (if present)
    'linkOptions' => [],
]);

php composer.phar