fix blog details
This commit is contained in:
@@ -46,6 +46,9 @@ class BaseController extends Controller
|
|||||||
* @param ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
protected $session = [];
|
||||||
|
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
// Do Not Edit This Line
|
// Do Not Edit This Line
|
||||||
@@ -106,25 +109,44 @@ class BaseController extends Controller
|
|||||||
return json_decode($result, true);
|
return json_decode($result, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getBlogOneItem($postId) :array {
|
||||||
|
$siteData = $this->getBlogItems();
|
||||||
|
$blogItem = $siteData['blogdata'][0];
|
||||||
|
$blogItem['blog_media_url'] = $siteData['blog_media_url'];
|
||||||
|
return $blogItem;
|
||||||
|
}
|
||||||
protected function getBlogItems() :array {
|
protected function getBlogItems() :array {
|
||||||
$apiEndpointsConfig = config('ApiEndpoints');
|
$siteData =[];
|
||||||
$wpData = WpContentsClient::serviceGetBlogItems($apiEndpointsConfig->baseUrl);
|
|
||||||
$blog_post = array();
|
if ( count( $this->session->get("siteData")) > 0 ){
|
||||||
$blog_cnt =0;
|
return $this->session->get("siteData");
|
||||||
foreach ($wpData[0]->payload as $item) {
|
|
||||||
$itemA = array(
|
|
||||||
'title' => $item->post_title,
|
|
||||||
'desc' => substr($item->post_content,0,100),
|
|
||||||
'link' => $item->guid,
|
|
||||||
'date' => date_format(date_create( $item->post_date),'Y-m-d'),
|
|
||||||
'image' => "https://blog.mermsemr.com/wp-content/uploads/".$item->meta_value,
|
|
||||||
);
|
|
||||||
if ($blog_cnt == 0){
|
|
||||||
$this->session->blogItem = $itemA ;
|
|
||||||
}
|
|
||||||
$blog_cnt++;
|
|
||||||
array_push($blog_post, $itemA);
|
|
||||||
}
|
}
|
||||||
return $blog_post;
|
$out = $this->APIcall('GET','http://10.10.10.35:8805/blogdata/coregrade',[]);
|
||||||
|
$siteData['blogdata'] = is_array( $out['payload']['blogdata']) ? $out['payload']['blogdata'] : [];
|
||||||
|
$siteData['blog_media_url'] = $out['payload']['image_url'];
|
||||||
|
|
||||||
|
$this->session->set("siteData",$siteData);
|
||||||
|
|
||||||
|
return $siteData;
|
||||||
|
|
||||||
|
// $apiEndpointsConfig = config('ApiEndpoints');
|
||||||
|
// $wpData = WpContentsClient::serviceGetBlogItems($apiEndpointsConfig->baseUrl);
|
||||||
|
// $blog_post = array();
|
||||||
|
// $blog_cnt =0;
|
||||||
|
// foreach ($wpData[0]->payload as $item) {
|
||||||
|
// $itemA = array(
|
||||||
|
// 'title' => $item->post_title,
|
||||||
|
// 'desc' => substr($item->post_content,0,100),
|
||||||
|
// 'link' => $item->guid,
|
||||||
|
// 'date' => date_format(date_create( $item->post_date),'Y-m-d'),
|
||||||
|
// 'image' => "https://blog.mermsemr.com/wp-content/uploads/".$item->meta_value,
|
||||||
|
// );
|
||||||
|
// if ($blog_cnt == 0){
|
||||||
|
// $this->session->blogItem = $itemA ;
|
||||||
|
// }
|
||||||
|
// $blog_cnt++;
|
||||||
|
// array_push($blog_post, $itemA);
|
||||||
|
// }
|
||||||
|
// return $blog_post;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,19 @@ class Home extends BaseController
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$siteData =[];
|
// $siteData =[];
|
||||||
$out = $this->APIcall('GET','http://10.10.10.35:8805/blogdata/coregrade',[]);
|
// $out = $this->APIcall('GET','http://10.10.10.35:8805/blogdata/coregrade',[]);
|
||||||
$siteData['blogdata'] = is_array( $out['payload']['blogdata']) ? $out['payload']['blogdata'] : [];
|
// $siteData['blogdata'] = is_array( $out['payload']['blogdata']) ? $out['payload']['blogdata'] : [];
|
||||||
$siteData['blog_media_url'] = $out['payload']['image_url'];
|
// $siteData['blog_media_url'] = $out['payload']['image_url'];
|
||||||
|
|
||||||
|
$siteData = $this->getBlogItems();
|
||||||
|
|
||||||
return view('web/index',$siteData);
|
return view('web/index',$siteData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blog()
|
public function blog()
|
||||||
{
|
{
|
||||||
$siteData =[];
|
$siteData = $this->getBlogItems();
|
||||||
$out = $this->APIcall('GET','http://10.10.10.35:8805/blogdata/coregrade',[]);
|
|
||||||
$siteData['blogdata'] = is_array( $out['payload']['blogdata']) ? $out['payload']['blogdata'] : [];
|
|
||||||
$siteData['blog_media_url'] = $out['payload']['image_url'];
|
|
||||||
// $data = array();
|
// $data = array();
|
||||||
// $data["blog_post"] =$this->getBlogItems(); // $blog_post;
|
// $data["blog_post"] =$this->getBlogItems(); // $blog_post;
|
||||||
//var_dump( $siteData);
|
//var_dump( $siteData);
|
||||||
@@ -47,7 +46,8 @@ class Home extends BaseController
|
|||||||
|
|
||||||
public function blogdetails()
|
public function blogdetails()
|
||||||
{
|
{
|
||||||
return view('web/blog-details');
|
$currentPost = $this->getBlogOneItem(13);
|
||||||
|
return view('web/blog-details',$currentPost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function security()
|
public function security()
|
||||||
|
|||||||
@@ -33,11 +33,11 @@
|
|||||||
<div class="project-details">
|
<div class="project-details">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<h2 class="title">Ethical considerations for AI-powered</h2>
|
<h2 class="title"><?=$post_title?></h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="image">
|
<div class="image">
|
||||||
<img src="/asset/images/project/project-details.jpg" alt="Image"/>
|
<img style="width: 100%;" src="<?=$blog_media_url?>/<?=$meta_value?>" alt="<?=$post_title?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user