diff --git a/app/Config/ApiEndpoints.php b/app/Config/ApiEndpoints.php new file mode 100644 index 0000000..f24b0ff --- /dev/null +++ b/app/Config/ApiEndpoints.php @@ -0,0 +1,34 @@ + '', + 'password' => '' + ]; +} diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4a5dd5c..d1b2a77 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -43,7 +43,7 @@ $routes->get('/howitworks', 'Home::howitworks'); $routes->get('/tools', 'Tools::index'); -$routes->get('/blog', 'Tools::index'); +$routes->get('/blog', 'Home::blog'); /* * -------------------------------------------------------------------- * Additional Routing diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 5a1946b..d78786d 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -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; + } } diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 9fb07a5..27167bf 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -1,6 +1,7 @@ getBlogItems(); // $blog_post; + return view('blog/index',$data); + } } diff --git a/app/Services/WpContentsClient.php b/app/Services/WpContentsClient.php new file mode 100644 index 0000000..82c3f73 --- /dev/null +++ b/app/Services/WpContentsClient.php @@ -0,0 +1,19 @@ +request( + 'GET', + "{$apiEndpointsUrl}/wordpress-data" + ); + return json_decode($response->getBody()); + } +} + + diff --git a/app/Views/blog/index.php b/app/Views/blog/index.php new file mode 100644 index 0000000..a90cd0f --- /dev/null +++ b/app/Views/blog/index.php @@ -0,0 +1,91 @@ += $this->extend('layouts/homelayout2') ?> += $this->section('content') ?> +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | - | - | - | - | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
-
-
+
+
-
+
+
-
-
-
+
+
-
-
-
-
+
+
+
-
-
+
+
+
+
-
-
-
+
+
-
-
-
-
+
+
+
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
- Todo-
-
-
-
-
+
-
-
-
-
-
-
-
-
- Payments
-
- Create Invoice
-
-
-
-
- Create Payment
-
-
-
-
-
- Generate Bill
-
-
-
-
-
- Subscription
-
+
-
-
-
-
-
-
-
- Settings
-
-
- |
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+