Fetching Custom Tags
Latch's form editor includes a Tags datatype powered by the Tagify vendor library.
Tags are used in several default forms. For example, pages can have Categories.
To check whether a post has a category:
<?php
if ($_SESSION["latch"]->db->has_tag("post", $post_id, "Categories", $category))
{
echo "This post has category " . \Latch\Input\sanitize("html", $category);
}
The first argument, $context, tells Latch which database table to inspect.
Supported contexts include:
post: Checkslatch_posts.field: Checks form fields inlatch_forms.group,role, orparent: Checkslatch_parents.
When checking parent metadata fields other than the default tags field, pass the metadata field name as the third argument and the tag value as the fourth argument:
<?php
$can_read = $_SESSION["latch"]->db->has_tag("group", $form_id, "read-permissions", "Administrator");