Blog page added

This commit is contained in:
Olu Amey
2021-09-19 16:23:46 -04:00
parent ffcf8593b5
commit 9420c6c1af
8 changed files with 5479 additions and 5300 deletions
+24
View File
@@ -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;
}
}