Blog page added
This commit is contained in:
@@ -8,6 +8,7 @@ use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Services\WpContentsClient;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
@@ -54,5 +55,28 @@ class BaseController extends Controller
|
||||
// Preload any models, libraries, etc, here.
|
||||
//--------------------------------------------------------------------
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
$this->session = \Config\Services::session();
|
||||
}
|
||||
|
||||
protected function getBlogItems() :array {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user