Add simple gallery.
This commit is contained in:
parent
d8d4279c69
commit
4ce532cf65
5 changed files with 66 additions and 2 deletions
31
application/controllers/gallery.php
Normal file
31
application/controllers/gallery.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Gallery extends CI_Controller {
|
||||||
|
public function index() {
|
||||||
|
$this->load->model('fileupload');
|
||||||
|
$this->load->library('pagination');
|
||||||
|
|
||||||
|
$page_count = 20;
|
||||||
|
$start = $this->uri->segment($this->uri->total_segments(), 1);
|
||||||
|
|
||||||
|
if($start == 'index') $start = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$config = array(
|
||||||
|
'base_url' => base_url('/gallery/index/'),
|
||||||
|
'total_rows' => $this->fileupload->count_uploads(),
|
||||||
|
'per_page' => $page_count
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->pagination->initialize($config);
|
||||||
|
|
||||||
|
$this->data['pagination'] = $this->pagination->create_links();
|
||||||
|
$this->data['uploads'] = $this->fileupload->get_uploads($start, $page_count);
|
||||||
|
|
||||||
|
$this->template->load('template', 'gallery', $this->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -34,13 +34,13 @@ class Upload extends CI_Controller {
|
||||||
'create_thumb' => true,
|
'create_thumb' => true,
|
||||||
'maintain_ratio' => true,
|
'maintain_ratio' => true,
|
||||||
'width' => 175,
|
'width' => 175,
|
||||||
'height' => 50,
|
'height' => 175,
|
||||||
'new_image' => './thumbs/' . $file_name . $upload['file_ext'],
|
'new_image' => './thumbs/' . $file_name . $upload['file_ext'],
|
||||||
'thumb_marker' => '',
|
'thumb_marker' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->load->library('image_lib',$config);
|
$this->load->library('image_lib',$config);
|
||||||
|
|
||||||
if($this->image_lib->resize() != true) echo 'dead to me.';
|
if($this->image_lib->resize() != true) echo 'dead to me.';
|
||||||
|
|
||||||
echo $this->image_lib->display_errors();
|
echo $this->image_lib->display_errors();
|
||||||
|
|
|
@ -32,6 +32,12 @@ class Fileupload extends CI_Model {
|
||||||
function add_view($id) {
|
function add_view($id) {
|
||||||
$this->db->query("UPDATE uploads SET views = views + 1 WHERE id = $id");
|
$this->db->query("UPDATE uploads SET views = views + 1 WHERE id = $id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_uploads($start = false, $count = false) {
|
||||||
|
$query = $this->db->get('uploads', $count, $start);
|
||||||
|
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
9
application/views/gallery.php
Normal file
9
application/views/gallery.php
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php echo $pagination; ?>
|
||||||
|
|
||||||
|
<div id="imageContainer" style="width: 960px;margin: auto;">
|
||||||
|
<?php foreach($uploads as $upload) { ?>
|
||||||
|
<div id="galleryContainer">
|
||||||
|
<img src="<?php echo base_url('/thumbs/' . $upload->id . $upload->extension); ?>" />
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
|
@ -262,6 +262,7 @@ h1{
|
||||||
--------------------------*/
|
--------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#left {
|
#left {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -284,4 +285,21 @@ h1{
|
||||||
display: block;
|
display: block;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------
|
||||||
|
Gallery
|
||||||
|
--------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#galleryContainer {
|
||||||
|
width: 175px;
|
||||||
|
height: 175px;
|
||||||
|
float: left;
|
||||||
|
margin: 5px;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
Loading…
Reference in a new issue