blog filter added
This commit is contained in:
@@ -12,9 +12,13 @@ class WrenchBlog extends BaseController
|
||||
protected $db;
|
||||
public $con_name = 'wrench_blog';
|
||||
|
||||
private function apiData() {
|
||||
private function apiData($blog_id) {
|
||||
$this->db = \Config\Database::connect($this->con_name);
|
||||
$data = array();
|
||||
$extra_filter = "";
|
||||
if ($blog_id > 0 ){
|
||||
$extra_filter = " AND p1.id = $blog_id ";
|
||||
}
|
||||
|
||||
try {
|
||||
$mysql = "SELECT id, post_title, post_content,post_date,comment_count FROM wp_posts WHERE post_type='post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 9";
|
||||
@@ -25,7 +29,7 @@ class WrenchBlog extends BaseController
|
||||
ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL )
|
||||
WHERE
|
||||
p1.post_status='publish'
|
||||
AND p1.post_type='post'
|
||||
AND p1.post_type='post' $extra_filter
|
||||
ORDER BY p1.post_date DESC LIMIT 2000";
|
||||
|
||||
$query = $this->db->query($mysql);
|
||||
@@ -67,21 +71,32 @@ class WrenchBlog extends BaseController
|
||||
|
||||
public function website(){
|
||||
|
||||
$blog_id = 0;
|
||||
// echo "EXYTACT INPUT DATA HERE";
|
||||
$raw_json = file_get_contents('php://input');
|
||||
$in = json_decode($raw_json, true);
|
||||
|
||||
log_message('critical', "BLOG DATA CALL ********* ".serialize($in) );
|
||||
|
||||
|
||||
$endpoint = "WRENCH_BLOG_DATA";
|
||||
$res1 = $this->getCache($endpoint);
|
||||
if (count($res1)==0){
|
||||
$rawData = $this->apiData();
|
||||
$res1= $rawData['payload']; //[0]['payload'];
|
||||
$this->saveCache($endpoint,$res1);
|
||||
if (isset($in['blog_id'])){
|
||||
$blog_id = (int) $in['blog_id'];
|
||||
}
|
||||
|
||||
if ($blog_id > 0 ){
|
||||
$rawData = $this->apiData($blog_id);
|
||||
$res1= $rawData['payload']; //[0]['payload'];
|
||||
}
|
||||
else{
|
||||
$endpoint = "WRENCH_BLOG_DATA";
|
||||
$res1 = $this->getCache($endpoint);
|
||||
if (count($res1)==0){
|
||||
$rawData = $this->apiData($blog_id);
|
||||
$res1= $rawData['payload']; //[0]['payload'];
|
||||
$this->saveCache($endpoint,$res1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$limit = isset($in['limit']) ? $in['limit']: 0;
|
||||
if ($limit> 0){
|
||||
$res1['blogdata'] = array_slice($res1['blogdata'], 0, $limit);
|
||||
|
||||
Reference in New Issue
Block a user