forked from jenkoian/pyrocms-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
53 lines (46 loc) · 1.68 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Portfolio Plugin
*
* Create lists of portfolio items
*
* @package PyroCMS
* @author Ian Jenkins
*
*/
class Plugin_Portfolio extends Plugin {
/**
* Portfolio List
*
* Creates a list of portfolio items
*
* Usage:
* {pyro:portfolio:items limit="5"}
* <h2>{pyro:title}</h2>
* {pyro:body}
* {/pyro:portfolio:items}
*
* @param array
* @return array
*/
function items($data = array()) {
$limit = $this->attribute('limit', 10);
$client = $this->attribute('client');
$order_by = $this->attribute('order-by', 'created_on');
$order_dir = $this->attribute('order-dir', 'ASC');
if ($client) {
$this->db->where($this->db->dbprefix('portfolio_clients').'.' . (is_numeric($client) ? 'id' : 'slug'), $client);
}
return $this->db
->select($this->db->dbprefix('portfolio').'o.*, '.$this->db->dbprefix('portfolio_clients').'.title as client_name, '.$this->db->dbprefix('portfolio_clients').'.slug as client_slug')
->where('status', 'live')
->where('created_on <=', now())
->join($this->db->dbprefix('portfolio_clients'), $this->db->dbprefix('portfolio').'.client_id = '.$this->db->dbprefix('portfolio_clients').'.id', 'LEFT')
->order_by($this->db->dbprefix('portfolio').'.' . $order_by, $order_by)
->limit($limit)
->get($this->db->dbprefix('portfolio'))
->result_array();
}
}
/* End of file plugin.php */