![]() |
Json Handling in ViewCI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Json Handling in ViewCI (/showthread.php?tid=67123) |
Json Handling in ViewCI - shakeelahmed.cfs - 01-18-2017 hey everyone .. I am a nwebiew to CI and a fresher too neeed your help , I have a wordpress blog from where i have fetch posts through JSON and tat JSON data i want to view in CI VIEW i am sharing the code of controller Code: <?php so please tell me how i can show my posts and tiles of posts in the view RE: Json Handling in ViewCI - neuron - 01-18-2017 $json_posts = file_get_contents('http://wordpress-34240-73651-202010.cloudwaysapps.com/wp-json/wp/v2/posts'); $data['posts'] = json_decode($json_posts); then in /view/post.php foreach($posts as $key => $post){} RE: Json Handling in ViewCI - shakeelahmed.cfs - 01-18-2017 (01-18-2017, 01:31 AM)neuron Wrote: $json_posts = file_get_contents('http://wordpress-34240-73651-202010.cloudwaysapps.com/wp-json/wp/v2/posts');if u dont mind can please tell me how to do the same with jquery and thanx for replying it on short time RE: Json Handling in ViewCI - Diederik - 01-18-2017 http://lmgtfy.com/?q=jquery+json+decode RE: Json Handling in ViewCI - shakeelahmed.cfs - 01-18-2017 (01-18-2017, 05:00 AM)Diederik Wrote: http://lmgtfy.com/?q=jquery+json+decode Thank You... its appreciated well i have found out to handle it just did the chnages in controllers and view controller -> $content = file_get_contents('http://wordpress-34240-73651-202010.cloudwaysapps.com/wp-json/wp/v2/posts'); $content=json_decode($content,true); $data=array('decodes'=>$content); $this->load->view('post',$data); and in view i handled it like this <?php foreach ($decodes as $decode) : ?> <tr> <td><?php echo $decode['title']['rendered']; ?></td> <td><?php echo $decode['date']; ?></td> <td><?php echo $decode['content']['rendered']; ?></td> </tr> <?php endforeach ?> RE: Json Handling in ViewCI - shakeelahmed.cfs - 01-18-2017 (01-18-2017, 02:49 AM)shakeelahmed.cfs Wrote:(01-18-2017, 01:31 AM)neuron Wrote: $json_posts = file_get_contents('http://wordpress-34240-73651-202010.cloudwaysapps.com/wp-json/wp/v2/posts');if u dont mind can please tell me how to do the same with jquery and thanx for replying it on short time Thank You... its appreciated well i have found out to handle it just did the chnages in controllers and view controller -> $content = file_get_contents('http://wordpress-34240-73651-202010.cloudwaysapps.com/wp-json/wp/v2/posts'); $content=json_decode($content,true); $data=array('decodes'=>$content); $this->load->view('post',$data); and in view i handled it like this <?php foreach ($decodes as $decode) : ?> <tr> <td><?php echo $decode['title']['rendered']; ?></td> <td><?php echo $decode['date']; ?></td> <td><?php echo $decode['content']['rendered']; ?></td> </tr> <?php endforeach ?> |