Content
Each controller generates a different data type. Some gives single array ,2D array and strings.
We've divided it into four major sections. We set a where condition for each controller's function.This will decide for which type of data we get.
We'll study each in depth with example.
This section consist of four sub parts. Its simple once you get the logic. Read all the four section for detailed information.
Single Post {where='post'}
First one is single post
In this section we receive an array
- $post['title_link']
- $post['author_name']
- $post['categories']
- $post['content']
- $post['read_comments']
- $post['comment_form']
HTML code for above array
//single post <h2><?=$post['title_link']?></h2> <p class="post-info"> Posted by <?=$post['author_name']?> | Filed under <?=$post['categories']?> </p> <p><?=$post['content']?></p> <p><?=$post['read_comments']?></p> <p><?=$post['comment_form']?></p>
2D Array {where='loop'}
Second type is 2d array. Each single value of array contains
- $blogmer['date']
- $blogmer['post_title']
- $blogmer['post_status']
- $blogmer['content']
- $blogmer['categories']
- $blogmer['author_name']
- $blogmer['title_link']
- $blogmer['comment_link]
- $blogmer['comment_no']
- $blogmer['total_comments']
- $blogmer['full']
So to get data we need to execute loop.
Here is live code example
for($i=0;$i<count($allposts)-1;$i++)
{
$comments=base_url().'blog/post/'.url_title($allposts[$i]['post_title']).'#comments'; ?>
<h2><?=$allposts[$i]['title_link'];?></h2>
<p class="post-info">Posted by <?=$allposts[$i]['author_name'];?> | Filed under <?=$allposts[$i]['categories'];?> </p>
<p><?=$allposts[$i]['content'];?></p>
<p class="post-footer">
<a href="<?=$comments?>" class="comments">Comments : <?=$allposts[$i]['comment_no'];?></a>
<span class="date"><?=$allposts[$i]['date'];?></span>
</p>
<?php
} //end of for loop
?>
Array with 2 value {where='page'}
An array returns 2 values.
- $page[title_link']
- $page['content']
<h2><?=$page['title_link']?></h2> <p><?=$page['content']?></p>
Single variable {where='single'}
Returns a $content variable. It contains string based html output;
<?php break; case 'single': ?> <p><?=$content?></p>