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
54
55
56
57
58
59
60
<?php         
        /** 
	 * Return ProductGroups as children of the current page
	 */         
         function ChildGroups() {

		return DataObject::get("ProductGroup", "ShowInMenus = 1 AND ParentID = " . $this->ID);
	
         }
	

	/**
	 * Returns the Products as children of the current page.
	 */
	public function ChildProducts() {
		return DataObject::get("Product", "ShowInMenus = 1 AND ParentID = " . $this->ID);
		
	}
	
	/**
	 * Returns the Products as children of the current page with pagination.
	 */
	
	function ProductListPagination() {
		
		if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
		$SQL_start = (int)$_GET['start'];
		$doSet = DataObject::get(
			$callerClass = "Product",
			$filter = "`ParentID` = '".$this->ID."'",
			$sort = "",
			$join = "",
			$limit = "{$SQL_start},2"
		);
		
		return $doSet ? $doSet : false;
	}
?>


         /**
	 * Silverstripe code, to display the Product list for Layer 1!!
	 */

<% if ChildGroups %>
			<div class="product_summary">
				
				<% control level(3) %>	
					<ul id="ProductList">
						<% control ChildGroups %>
							<% if ChildProducts %>
								<% control ProductListPagination %>
										<% include ProductGroupItem %>
								<% end_control %>
							<% end_if %>
						<% end_control %>
					</ul>
				<% end_control %>
			</div>
<% end_if %>