public function Articles() { if ($this->TagID) { $this->fetch(); return $this->Tag()->Articles()->sort('Date', 'DESC'); } else { return HailArticle::get()->sort('Date', 'DESC'); } }
private function processFeaturedArticle($articleData) { if ($articleData) { $article = HailArticle::get()->filter(array('HailID' => $articleData->id))->first(); if (!$article) { $article = new HailArticle(); } $article->importHailData($articleData); $heroImage = $article->HeroImageID; $article = $article->ID; } else { $article = null; } $this->FeaturedArticleID = $article; if (isset($heroImage) && $heroImage) { $this->HeroImageID = $heroImage; } }
public function fetchArticles() { try { $list = HailApi::getArticlesByTag($this->HailID); } catch (HailApiException $ex) { Debug::warningHandler(E_WARNING, $ex->getMessage(), $ex->getFile(), $ex->getLine(), $ex->getTrace()); return; } $hailIdList = array(); foreach ($list as $hailData) { // Build up Hail ID list $hailIdList[] = $hailData->id; // Check if we can find an existing item. $hailObj = HailArticle::get()->filter(array('HailID' => $hailData->id))->First(); if (!$hailObj) { $hailObj = new HailArticle(); } $hailObj->importHailData($hailData); $this->Articles()->add($hailObj); } $this->Articles()->exclude('HailID', $hailIdList)->removeAll(); }
protected function fetchMethod() { HailArticle::fetch(); }
/** * Action to display a sepcific {@link HailArticle} * * @param SS_HTTPRequest $request * @return HTMLText First Article with image */ public function hailarticle($request) { $this->myArticle = HailArticle::get()->byID($request->param('ID')); $this->myArticle->refresh(); if ($this->myArticle->Content) { $this->myArticle->softRefresh(); } else { $this->myArticle->refresh(); } return $this->customise(array('Title' => $this->myArticle->Title))->renderWith(array('HailHolder_HailArticle', 'Page')); }