Blog page added
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Config;
|
||||||
|
|
||||||
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
|
class ApiEndpoints extends BaseConfig
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
* Base Url
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* WP Data Gateway endpoint base url
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $baseUrl = 'http://172.31.4.19:8000';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
* Client Credentials
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Client credentials
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $clientCredentials = [
|
||||||
|
'username' => '',
|
||||||
|
'password' => ''
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ $routes->get('/howitworks', 'Home::howitworks');
|
|||||||
$routes->get('/tools', 'Tools::index');
|
$routes->get('/tools', 'Tools::index');
|
||||||
|
|
||||||
|
|
||||||
$routes->get('/blog', 'Tools::index');
|
$routes->get('/blog', 'Home::blog');
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
* Additional Routing
|
* Additional Routing
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use CodeIgniter\HTTP\IncomingRequest;
|
|||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use App\Services\WpContentsClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BaseController
|
* Class BaseController
|
||||||
@@ -54,5 +55,28 @@ class BaseController extends Controller
|
|||||||
// Preload any models, libraries, etc, here.
|
// Preload any models, libraries, etc, here.
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// E.g.: $this->session = \Config\Services::session();
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
use App\Services\WpContentsClient;
|
||||||
|
|
||||||
class Home extends BaseController
|
class Home extends BaseController
|
||||||
{
|
{
|
||||||
@@ -38,4 +39,10 @@ class Home extends BaseController
|
|||||||
{
|
{
|
||||||
return view('home/howitworks');
|
return view('home/howitworks');
|
||||||
}
|
}
|
||||||
|
public function blog()
|
||||||
|
{
|
||||||
|
$data = array();
|
||||||
|
$data["blog_post"] =$this->getBlogItems(); // $blog_post;
|
||||||
|
return view('blog/index',$data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
use GuzzleHttp\Client as HTTPClient;
|
||||||
|
|
||||||
|
class WpContentsClient
|
||||||
|
{
|
||||||
|
public static function serviceGetBlogItems($apiEndpointsUrl)
|
||||||
|
{
|
||||||
|
$client = new HTTPClient();
|
||||||
|
$response = $client->request(
|
||||||
|
'GET',
|
||||||
|
"{$apiEndpointsUrl}/wordpress-data"
|
||||||
|
);
|
||||||
|
return json_decode($response->getBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<?= $this->extend('layouts/homelayout2') ?>
|
||||||
|
<?= $this->section('content') ?>
|
||||||
|
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
|
||||||
|
<!--begin::Post-->
|
||||||
|
<div class="post d-flex flex-column-fluid" id="kt_post">
|
||||||
|
<!--begin::Container-->
|
||||||
|
<div id="kt_content_container" class="container-xxl">
|
||||||
|
<!--begin::Home card-->
|
||||||
|
<div class="card">
|
||||||
|
<!--begin::Body-->
|
||||||
|
<div class="card-body p-lg-20">
|
||||||
|
|
||||||
|
<!--begin::Section-->
|
||||||
|
<div class="mb-17">
|
||||||
|
<!--begin::Content-->
|
||||||
|
<div class="d-flex flex-stack mb-5">
|
||||||
|
<!--begin::Title-->
|
||||||
|
<h3 class="text-black">Video Tutorials</h3>
|
||||||
|
<!--end::Title-->
|
||||||
|
<!--begin::Link-->
|
||||||
|
<a href="#" class="fs-6 fw-bold link-primary">View All Videos</a>
|
||||||
|
<!--end::Link-->
|
||||||
|
</div>
|
||||||
|
<!--end::Content-->
|
||||||
|
<!--begin::Separator-->
|
||||||
|
<div class="separator separator-dashed mb-9"></div>
|
||||||
|
<!--end::Separator-->
|
||||||
|
<!--begin::Row-->
|
||||||
|
<div class="row g-10">
|
||||||
|
<!--begin::Col-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach ($blog_post as $bitem) {
|
||||||
|
// print_r($bitem);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<!--begin::Feature post-->
|
||||||
|
<div class="card-xl-stretch me-md-6">
|
||||||
|
<!--begin::Image-->
|
||||||
|
<a class="d-block bgi-no-repeat bgi-size-cover bgi-position-center card-rounded position-relative min-h-175px mb-5" style="background-image:url('<?=$bitem['image']?>')" data-fslightbox="lightbox-video-tutorials" href="<?= $bitem['link']?>">
|
||||||
|
<img src="/tassets/media/svg/misc/video-play.svg" class="position-absolute top-50 start-50 translate-middle" alt="" />
|
||||||
|
</a>
|
||||||
|
<!--end::Image-->
|
||||||
|
<!--begin::Body-->
|
||||||
|
<div class="m-0">
|
||||||
|
<!--begin::Title-->
|
||||||
|
<a href="<?= $bitem['link']?>" class="fs-4 text-dark fw-bolder text-hover-primary text-dark lh-base"><?= $bitem['title'] ?> </a>
|
||||||
|
<!--end::Title-->
|
||||||
|
<!--begin::Text-->
|
||||||
|
<div class="fw-bold fs-5 text-gray-600 text-dark my-4"><?= $bitem['desc']?></div>
|
||||||
|
<!--end::Text-->
|
||||||
|
<!--begin::Content-->
|
||||||
|
<div class="fs-6 fw-bolder">
|
||||||
|
<!--begin::Author-->
|
||||||
|
<a href="../../demo8/dist/pages/profile/overview.html" class="text-gray-700 text-hover-primary">Jane Miller</a>
|
||||||
|
<!--end::Author-->
|
||||||
|
<!--begin::Date-->
|
||||||
|
<span class="text-muted"><?= $bitem['date'] ?></span>
|
||||||
|
<!--end::Date-->
|
||||||
|
</div>
|
||||||
|
<!--end::Content-->
|
||||||
|
</div>
|
||||||
|
<!--end::Body-->
|
||||||
|
</div>
|
||||||
|
<!--end::Feature post-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--end::Row-->
|
||||||
|
</div>
|
||||||
|
<!--end::Section-->
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--end::Body-->
|
||||||
|
</div>
|
||||||
|
<!--end::Home card-->
|
||||||
|
</div>
|
||||||
|
<!--end::Container-->
|
||||||
|
</div>
|
||||||
|
<!--end::Post-->
|
||||||
|
</div>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
File diff suppressed because it is too large
Load Diff
+1282
-5299
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user