Tags

To enable the use of tags, we provided a tags interface. To use this, all you have to do is implement this into your model.

namespace Frontend\Modules\MiniBlog\Engine;

use Frontend\Modules\Tags\Engine\TagsInterface as FrontendTagsInterface;

class Model implements FrontendTagsInterface

Now you're able to use the two functions provided by the Tags interface, getForTags(), which needs an array of ids and getIdForTags(), which needs the FrontendUrl instance.

Now all you need to do is fetch the correct data for these tags/url. It is fairly easy to fetch the data for the getForTags() function. You just need to select the items that have an id that is in our array and that are visible.

use Frontend\Core\Engine\Model as FrontendModel;
use Frontend\Core\Engine\Navigation as FrontendNavigation;

...

public static function getForTags(array $ids)
{
	$items = (array) FrontendModel::get('database')->getRecords(
		'SELECT i.title, m.url
		 FROM mini_blog AS i
		 INNER JOIN meta AS m ON m.id = i.meta_id
		 WHERE i.publish = ? AND i.id IN (' . implode(',', $ids) . ')
		 ORDER BY i.created DESC',
		array(true)
	);

	if (!empty($items)) {
		$link = FrontendNavigation::getUrlForBlock('MiniBlog', 'detail');
		foreach($items as $key => $row) $items[$key]['full_url'] = $link . '/' . $row['url'];
	}

	return $items;
}

Once implemented, the tags module will be able to call this functions and show the proper items. If you have any posts that have tags, you'll be able to see those tags on http://mysite.tld/tags. If you click that tag, you'll see the proper items for that specific tag.