Welcome Guest, Not a member yet? Register   Sign In
How to Archive for blog or magazin
#1

[eluser]Unknown[/eluser]
Hi
How to Archive of blog by month?
#2

[eluser]kirkaracha[/eluser]
Assuming URLs like example.com/blog/2011/07

In config/routes.php

Code:
$route['blog/(:num)/(:num)'] = 'blog/month/$1/$2';
$route['blog/(:num)'] = 'blog/year/$1/';

In controllers/blog.php

Code:
public $url_year;
public $url_month;

public function __construct() {
    parent::__construct();

    $this->url_year = $this->uri->segment(2,NULL);
    $this->url_month = $this->uri->segment(3,NULL);
}

public function year(){
// do a query for entries that match the year
}

public function month(){
// do a query for entries that match the year and month
}




Theme © iAndrew 2016 - Forum software by © MyBB