/**
* Load the data, don't forget to validate the incoming data
*/
private function getData()
{
// validate incoming parameters
if ($this->URL->getParameter(1) === null) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch record
$this->record = FrontendTagsModel::get($this->URL->getParameter(1));
// validate record
if (empty($this->record)) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch modules
$this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
// loop modules
foreach ($this->modules as $module) {
// get the ids of the items linked to the tag
$otherIds = (array) $this->get('database')->getColumn('SELECT other_id
FROM modules_tags
WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
// set module class
$class = 'Frontend\\Modules\\' . $module . '\\Engine\\Model';
// get the items that are linked to the tags
$items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
// add into results array
if (!empty($items)) {
$this->results[] = array('name' => $module, 'label' => FL::lbl(\SpoonFilter::ucfirst($module)), 'items' => $items);
}
}
}