Skip to content

KonstantinKolodnitsky/x_tags

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

x_tags


tags plugin for atk4

Requires: git@github.com:atk4/autocomplete.git

This plugin allows you to add tags to any Model.

Instalation:

Just clone to addons dirrectory of your atk4 project

Usage:

Add Tags:

Add form (I suggest to set id of form manually by passing second parameter to add())

$f=$this->add('Form','bform');

Set Model for Form which has 'tags' Field (->type('text'))

$f->setModel('Model_Article',array('title','text','tags'));

Add Form_Tags and connect to your Form

$this->add('x_tags/Form_Tags',array('connected_form'=>$f));

Form_Tag will add Lister to your page which requires Tag in page template.

Screenshot

Show Tags:

You can use Lister_Tag to show tags with no Form_Tags as well. This is example how to use it with Grid

function formatRow(){
    parent::formatRow();

        // tag cloud
        if ($this->current_row['tags']) {
            $t = $this->add('x_tags/Lister_Tags','tags_cl_'.$this->current_row['id'],'content');
            $temp_tag_arr = explode(',',$this->current_row['tags']);
            $tag_arr = array();
            $count = 0;
            foreach ($temp_tag_arr as $tag) {
                $tag_arr[$count++]['value'] = $tag;
            }
            $t->setSource($tag_arr,'value');
            $this->current_row_html['tag_cloud']=$t->getHTML();
        } else {
            $this->current_row_html['tag_cloud'] = '';
        }
}

Screenshot

Same for CompleteLister

class Lister_Notes extends CompleteLister {
    function formatRow(){
        // tag cloud
        if ($this->current_row['tags']) {
            $t = $this->add('x_tags/Lister_Tags','tags_cl_'.$this->current_row['id']);
            $temp_tag_arr = explode(',',$this->current_row['tags']);
            $tag_arr = array();
            $count = 0;
            foreach ($temp_tag_arr as $tag) {
                $tag_arr[$count++]['value'] = $tag;
            }
            $t->setSource($tag_arr,'value');
            $this->current_row_html['tag_cloud']=$t->getHTML();
        } else {
            $this->current_row_html['tag_cloud'] = '';
        }
    }
}

Edit Tags:

$f=$this->add('Form','bform','form');    
$f->setModel('Model_Article',array('title','text','tags'));    
$f->addSubmit('Update');
$this->add('x_tags/Form_Tags',array('connected_form'=>$f));

github README.md formating http://daringfireball.net/projects/markdown/syntax#html

About

tags plugin for atk4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 82.9%
  • JavaScript 12.9%
  • CSS 4.2%