changes the db query and adopts the layout of the Vue component to show the correct betreff and content of the news

This commit is contained in:
SimonGschnell
2024-06-26 13:21:32 +02:00
parent f546554f87
commit 478adb740e
5 changed files with 45 additions and 55 deletions
+23 -25
View File
@@ -109,35 +109,33 @@ class Cms extends FHCAPI_Controller
public function news()
{
$this->load->model('content/news_model', 'NewsModel');
$limit = $this->input->get('limit',TRUE);
// return early if the limit parameter is missing or is not greater than 0
if(!isset($limit) || $limit > 0)
$this->terminateWithError("API parameters are missing", self::ERROR_TYPE_GENERAL);
$this->load->model('content/news_model', 'NewsModel');
$news_content_ids = $this->NewsModel->getNewsContentIDs($limit);
$news_metadata = $this->NewsModel->getAll($limit);
$this->addMeta("content_ids",$news_content_ids);
$news_content = array();
// return early if the limit parameter is missing or is not greater than 0
if(!isset($limit) || $limit < 1)
$this->terminateWithError("API parameters are missing", self::ERROR_TYPE_GENERAL);
if(isError($news_content_ids))
$this->terminateWithError(getError($news_content_ids), self::ERROR_TYPE_GENERAL);
if(isError($news_metadata))
$this->terminateWithError(getError($news_metadata), self::ERROR_TYPE_GENERAL);
foreach(getData($news_content_ids) as $content_id){
$news_content[] = $this->fetchContent($content_id->content_id);
//query the news
$news = $this->NewsModel->getAll($limit);
//get the data or terminate with error
$news = $this->getDataOrTerminateWithError($news);
// check if any news are there
if($news === NULL){
$this->terminateWithError("No news content has been found");
}
$this->terminateWithSuccess(["news_content" =>$news_content, "news_metadata"=>getData($news_metadata)]);
// collect the content of the news
foreach($news as $news_element){
$this->addMeta("asdfs",$news_element->content_id);
$news_element->content_obj = $this->fetchContent($news_element->content_id);
}
$this->terminateWithSuccess($news);
}