Frontend\Modules\Tags\Engine\Model::getForItem PHP Method

getForItem() public static method

Get tags for an item
public static getForItem ( string $module, integer $otherId ) : array
$module string The module wherein the otherId occurs.
$otherId integer The id of the item.
return array
    public static function getForItem($module, $otherId)
    {
        $module = (string) $module;
        $otherId = (int) $otherId;
        // init var
        $return = array();
        // get tags
        $linkedTags = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT t.tag AS name, t.url
             FROM modules_tags AS mt
             INNER JOIN tags AS t ON mt.tag_id = t.id
             WHERE mt.module = ? AND mt.other_id = ?', array($module, $otherId));
        // return
        if (empty($linkedTags)) {
            return $return;
        }
        // create link
        $tagLink = FrontendNavigation::getURLForBlock('Tags', 'Detail');
        // loop tags
        foreach ($linkedTags as $row) {
            // add full URL
            $row['full_url'] = $tagLink . '/' . $row['url'];
            // add
            $return[] = $row;
        }
        // return
        return $return;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * 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));
     }
     // get by URL
     $this->record = FrontendFaqModel::get($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Detail') . '/' . $this->record['url'];
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('Faq', $this->record['id']);
     // get settings
     $this->settings = $this->get('fork.settings')->getForModule('Faq');
     // reset allow comments
     if (!$this->settings['allow_feedback']) {
         $this->record['allow_feedback'] = false;
     }
     // ge status
     $this->status = $this->URL->getParameter(2);
     if ($this->status == FL::getAction('Success')) {
         $this->status = 'success';
     }
     if ($this->status == FL::getAction('Spam')) {
         $this->status = 'spam';
     }
 }
All Usage Examples Of Frontend\Modules\Tags\Engine\Model::getForItem