Blogmer beta 2


Main_model

Main_model is core of blogmer.It contains all important functions.It generates post, page, feed in readable format from database.Let's discuss each function one by one.

Beta:  This is an Beta model. It can be changed anytime.

Functions:

$id : represents post id

Main_model Function Reference

$this->Main_model->SinglePostView($id,$full=false,$title="",$checktitle=false)

It takes 4 arguments. Only first one is essential. Rest are optional .It generates an array on the basis of 4 arguments.

We've ||more|| in blog posts so that we can short entry on home page and shows full when required

Array contains:

On Error :if id is not found it sets $blogmer['error'] to TRUE with $blomer['description']

$this->Main_model->PageLinks()

Generate li based list containing pages list with relative links.

Example output

<li><a href="blog path/features">Features</a></li>
<li><a href="blog path/blogmer-contact">Contact</a></li> <li><a href="blog path/about-speedovation">About Company</a></li>

I dropped <ul> part so that we add more external links without touching database.

See this example for better understanding.

<ul class="some-custom-class">
	<li id="current"><a href="external link">external info</a></li>
<li><a href="blog path/features">Features</a></li>
<li><a href="blog path/blogmer-contact">Contact</a></li> <li><a href="blog path/about-speedovation">About Company</a></li>
<ul>

This section can be found in theme/currenttheme/main.php

$this->Main_model->SinglePage($URLTitle)

Dt takes single arguments. It generates an array on the basis of $URLTitle.

$URLTitle is url title of page

Array contains:

On Error :if id is not found it sets $blogmer['error'] to TRUE with $blomer['description']

$this->Main_model->categories($cat)

Generate 2d array.

Contains :

 

Theme function to grab result from this function. It respect ||more|| .

<?php

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?>

This section can be found in theme/currenttheme/main.php

$this->Main_model->archives($date,$id)

Exaclty above only difference is when we're fetching data from database where condition is changed. For this we compare date basis ouput.

$this->Main_model->home($posts)

Exaclty above only difference is when we're fetching data from database there no condition.

$this->Main_model->get_recent_posts($number=10)

It return data from posts. It uses Active Record get function.This function is used by feed controller.

Final Collection

$this->load->model('Main_model');
$this->Main_model->SinglePostView($id,$full=false,$title="",$checktitle=false);
$this->Main_model->PageLinks();
$this->Main_model->SinglePage($URLTitle);
$this->Main_model->categories($cat,$title,$id);
$this->Main_model->archives($date,$id);
$this->Main_model->home($posts);
$this->Main_model->get_recent_posts($number=10);