';
if ($c['postImage'] != "") {
$posts .= '
';
$posts .= '
';
$posts .= '
'.date_format($date, 'd/m/Y').'
';
$posts .= '
'.$c['postExcerpt'].'
';
$posts .= '
Read More
';
} else {
$posts .= '
';
$posts .= '
'.date_format($date, 'd/m/Y').'
';
$posts .= '
'.$c['postExcerpt'].'
';
$posts .= '
Read More
';
}
$posts .= '
';
$posts .= "
";
endforeach;
echo $posts;
}
//Get the categories
function getCategories()
{
$CI =& get_instance();
$CI->db->order_by("categoryTitle", "asc");
$query=$CI->db->get('cm_post_category');
$categories = '
';
foreach ($query->result_array() as $c):
$CI->db->where('categoryID', $c['categoryID']);
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
if ($totPosts > 0) {
$categories .= '- '.$totPosts.''.$c['categoryTitle'].'
';
}
endforeach;
$categories .= "
";
echo $categories;
}
//Get the total posts
function countPosts($limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->from('cm_post');
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
echo "Showing posts ".$offset." - ".$showing." of ".$totPosts;
}
function countCategoryPosts($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->from('cm_post');
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
echo "Showing posts ".$offset." - ".$showing." of ".$totPosts;
}
function getPrevBtnCategory($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->from('cm_post');
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$prevNum = $offset-$limit;
if ($prevNum < 0) {
$prevNum = 0;
}
if ($prevNum < $offset) {
echo '
Previous';
}
}
function getNextBtnCategory($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->from('cm_post');
$CI->db->where('published', 1);
$CI->db->where('categoryID', $categoryID);
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
$nextNum = $offset+$limit;
if ($nextNum > $totPosts) {
} elseif ($nextNum <= $totPosts) {
$nextNum--;
echo '
Next';
}
}
function getPrevBtn($limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$prevNum = $offset-$limit;
if ($prevNum < 0) {
$prevNum = 0;
}
if ($prevNum < $offset) {
echo '
Previous';
}
}
function getNextBtn($limit=10, $offset=0)
{
$CI =& get_instance();
$totSegments = $CI->uri->total_segments();
$i=1;
$pagURL = "";
while ($i <= $totSegments) {
if (!is_numeric($CI->uri->segment($i))) {
$pagURL .= "/".$CI->uri->segment($i);
}
$i++;
}
$CI->db->where('published', 1);
$CI->db->from('cm_post');
$query = $CI->db->get();
$totPosts = $query->num_rows();
$showing = $offset+$limit;
if ($showing > $totPosts) {
$showing = $totPosts;
}
$offset++;
$nextNum = $offset+$limit;
if ($nextNum > $totPosts) {
} elseif ($nextNum <= $totPosts) {
$nextNum--;
echo '
Next';
}
}
//Get the Latest news for the main column
function getCategoryNews($categoryID, $limit=10, $offset=0)
{
$CI =& get_instance();
$CI->db->order_by("unixStamp", "desc");
$CI->db->limit($limit, $offset);
$CI->db->where('categoryID', $categoryID);
$CI->db->where('published', 1);
$query=$CI->db->get('cm_post');
$posts = '';
foreach ($query->result_array() as $c):
$date = new DateTime($c['datePosted']);
$posts .= '
';
if ($c['postImage'] != "") {
$posts .= '
';
$posts .= '
';
$posts .= '
'.date_format($date, 'd/m/Y').'
';
$posts .= '
'.$c['postExcerpt'].'
';
$posts .= '
Read More
';
} else {
$posts .= '
';
$posts .= '
'.date_format($date, 'd/m/Y').'
';
$posts .= '
'.$c['postExcerpt'].'
';
$posts .= '
Read More
';
}
$posts .= '
';
$posts .= "
";
endforeach;
echo $posts;
}
//Get the carousel
function getCarousel($id)
{
$CI =& get_instance();
$CI->db->order_by("slideOrder", "asc");
$CI->db->where("pageID", $id);
$query=$CI->db->get('cm_banner');
$carousel = '
'."\r\n";
$s = 0;
foreach ($query->result_array() as $c):
if ($s == 0) {
$carousel .= ''."\r\n";
} else {
$carousel .= ''."\r\n";
}
$s++;
endforeach;
$s = 0;
$carousel .= '
'."\r\n";
foreach ($query->result_array() as $c):
if ($s == 0) {
$carousel .= '
'."\r\n";
} else {
$carousel .= '
'."\r\n";
}
$s++;
endforeach;
$carousel .= "
"."\r\n";
echo $carousel;
}
//Get social
function getSocial()
{
$CI =& get_instance();
$CI->db->where("socialEnabled", 1);
$query=$CI->db->get('cm_social');
$social = '';
foreach ($query->result_array() as $c):
$social .= '
';
endforeach;
echo $social;
}