Archive

Posts Tagged ‘view’

What is MVC Architecture? (Model – View – Controller)

April 19th, 2009 71 comments

MVC Architecture has implemented by Trygve Reenskaug at 1979 for the first time. It was implemented on Smalltalk at Xerox labs. Then benefits and advantages of this architecture has been accepted by most of the coders and software engineers.

It was an information about MVC’s history above. Now lets talk about what really MVC is. What do you understand from MVC. The word M stands for Model, V stands for View and C stands for Controller. I am going to mention about each item.

The figure above may help you while thinking what structure it might have. Let’s start with Model.

Model:
It handles data processing and database works part. Model processes events sent by controller. After processing these events then it sends processed data to controller (thus, controller may reprocess it) or directly to view side.

View:
View prepares an interface to show to the user. Controller or model tells view what to show to the user. Also view handles requests from user and informs controller.

Read more…

VN:F [1.9.22_1171]
Rating: 8.4/10 (500 votes cast)
VN:F [1.9.22_1171]
Rating: +171 (from 203 votes)
Categories: General, Programming Tags: , , ,

CodeIgniter How to Pagination

November 12th, 2008 3 comments

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you’re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you’re tired of ponderously large and thoroughly undocumented frameworks.

CodeIgniter’s Pagination class is very easy to use, and it is 100% customizable, either dynamically or via stored preferences.

If you are not familiar with the term “pagination”, it refers to links that allows you to navigate from page to page, like this:

« First < 1 2 3 4 5 > Last »

function shownews()
{
if($this->userlib->logged_in()) 
//checking for security purposes
{
$this->load->library('pagination');
$per_page = 10; 
// How many pages you want to show in each page
$total = $this->db->get('posts', $per_page, $this->uri->segment(3)); 

//Here is the most important part actually. 
Basically $total variable determined which 
rows you are going to show in the page

$config['base_url'] = base_url().'/index.php/admin/shownews';
$config['total_rows'] = $this->db->count_all('posts'); // Count total rows in the query
$config['per_page'] = $per_page;
$config['num_links'] = 6;
$this->pagination->initialize($config);
$data['posts'] = $total;
$this->load->view('admin_shownews', $data);
} else {
$this->load->view('admin_logineed');
}
}

After getting done with this configuration part of pagination class all you have to do is just initialize it like you are doing it in most of programming languages.

Read more…

VN:F [1.9.22_1171]
Rating: 7.1/10 (41 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 5 votes)