smirik/propel-taggable-behavior

为对象添加标签功能。

该软件包的官方仓库似乎已消失,因此软件包已被冻结。

dev-master 2013-11-19 11:45 UTC

This package is not auto-updated.

Last update: 2021-07-09 21:31:53 UTC


README

安装

下载TaggableBehavior.php并将其放置在某个位置。

propel.behavior.taggable.class = path.to.taggable.behavior

如果您正在使用composer,则只需添加

{
    "require": {
        "smirik/propel-taggable-behavior": "*"
    }
}

ini-配置将是

propel.behavior.taggable.class = vendor.smirik.src.propel-taggable-behavior.src.TaggableBehavior

使用

行为创建两个持久表

  • tags (id, category_id, name)
  • tags_categories (id, name)

标签与标签类别相关联。关系字段category_id不是必需的。

添加到schema.xml

<behavior name="taggable" />

行为将为模型添加几个方法

public function addTags($tags, $category_id = null, PropelPDO $con = null)
public function removeTags($tags, $category_id = null)
public function addTag(Tag $tag)
public function removeTag(Tag $tag)

category_id是可选参数。

要求

鸣谢