SHOW:
|
|
- or go back to the newest paste.
1 | // Controller code: | |
2 | ||
3 | function PortfolioItems() { | |
4 | $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; | |
5 | $limit = 3; //set limit to how many portfolio items to show | |
6 | if (!isset($this->urlParams['Action']) || $this->urlParams['Action'] == 'All') | |
7 | $typeFilter = ""; | |
8 | else | |
9 | $typeFilter = "AND `PortfolioPage`.ProjectType='" . $this->urlParams['Action'] . "'"; | |
10 | ||
11 | - | return DataObject::get("PortfolioPage", "ParentID = $this->ID $typeFilter", "", "", "$start,$limit"); |
11 | + | $records = PortfolioPage::get()->filter(array( |
12 | "ParentID => $this->ID, | |
13 | ))->where($typeFilter); | |
14 | ||
15 | return PaginatedList::create($records, $this->request); | |
16 | ||
17 | } | |
18 | ||
19 | ||
20 | // template render: | |
21 | ||
22 | <% if PortfolioItems.MoreThanOnePage %> | |
23 | <div class="pagination"> | |
24 | <% if PortfolioItems.PrevLink %> | |
25 | <a href="$PortfolioItems.PrevLink"><span><img src="/themes/LittleMonkey2011/images/buttons/previous_off.png" id="previous" width="27" height="27" alt="previous" /></span></a> | |
26 | <% end_if %> | |
27 | ||
28 | <% control PortfolioItems.Pages %> | |
29 | <% if CurrentBool %> | |
30 | <span><img src="/themes/XX/images/buttons/page{$PageNum}_on.png" id="page{$PageNum}" width="27" height="27" alt="page{$PageNum}" /></span> | |
31 | <% else %> | |
32 | <a href="$Link"><span><img src="/themes/XX/images/buttons/page{$PageNum}_off.png" id="page{$PageNum}" width="27" height="27" alt="page{$PageNum}" /></span></a> | |
33 | <% end_if %> | |
34 | <% end_control %> | |
35 | <% if PortfolioItems.NextLink %> | |
36 | <a href="$PortfolioItems.NextLink"><span><img src="/themes/XX/images/buttons/next_off.png" id="next" width="27" height="27" alt="next" /></span></a> | |
37 | <% end_if %> | |
38 | </div> | |
39 | <% end_if %> |