Tags

From RedBean

Jump to: navigation, search

Tags

Tagging means labelling stuff. Tags are often used to categorize or group items into meaningful groups. In RedBean tagging has been build into the facade. Tagging beans is very easy. For instance, imagine we have a bean of type "page" and we would like to attach several tags to this bean "topsecret" and "mi6". Now here is how we attach these labels to the page bean:

R::tag( $page, "topsecret,mi6" );

As you see, the tagging system accepts a comma-separated string which chould come directly from your form module. However, the tag method also accepts arrays:

R::tag( $page, array("topsecret","mi6") );

To fetch all tags attached to a certain bean we use the same method but without the tag parameter:

$tags = R::tag( $page );

In this case the contents of variable $tags will equal the following string:

"topscret,mi6"

If you rather prefer an array you need to explode the return value of the function like this:

$tagItems = explode( ",", R::tag($page) );