Frontend

This part of the documentation should be read after going through the Getting Started documentation on Add to Cart, customising markup and checkout process.

Similar to ProcessWire, Padloper does not get in the way of your frontend content. Padloper does not output anything by itself (except for partial templates (files) needed for the checkout process). Instead, it provides a rich API that enables you to build your shop in any way you like. Every fine detail is left to you.

Behind the scenes, all Padloper features are ProcessWire pages. You have the full ProcessWire API at your disposal.

Access

Since Padloper pages are stored under /admin/ in ProcessWire, there is no direct access to them in the frontend via a URL. There are several ways the contents of Padloper pages can be output in the frontend including URL hooks and URL segments. We recommend the use of ProcessWire URL Segments for their simplicity. This will allow you to work directly in your template file.

Display Padloper Pages

The following examples demonstrate how to display various Padloper pages in the frontend using URL segments. You will need to enable URL segments for the templates of the pages you want to use to display Padloper pages. In all examples, we only allow one URL segment.

Example 1: Products

In this example, we want to display all or a limited number of products on our shop's Product's page. In case one product is selected, we want to display it instead. If there is more than one URL segment, we show a 404.

Step 1: Products Template

Create a template and template file called products. Enable URL segments (and optionally pagination) on the template.

Step 2: Products Code

$out = "";

// ----------
// first check if single product view requested
// @note: $beautify=true
$singleProductName = $sanitizer->pageName($input->urlSegment1, $beautify = true);
if (!empty($singleProductName)) {
	// get the product
	$product = $padloper->get("template=product,name={$singleProductName}");
	if ($product->id) {
		$out .=
			// product title
			"<h2>{$product->title}</h2>" .
			// append product description
			$product->padloper_description;
		// append a product image if available
		if ($product->padloper_images->count()) {
			$firstImage = $product->padloper_images->first();
			// product image thumb
			$thumb = $product->padloper_images->first()->width(400);
			// --------
			$out .= "<img src='{$thumb->url}' alt='{$product->title}'>";
		}
	} else {
		// unknown product: show 404
		throw new Wire404Exception();
	}
	$isShowSectionBackArrow = true;
	$title = $product->title;
} else {
	$products = $padloper->find("template=product,limit=12");
	foreach ($products as $product) {
		$out .=
			"<div>" .
			// product title
			"<p>{$product->title}</p>" .
			// append product description
			$product->padloper_description;
		// append a product image if available
		if ($product->padloper_images->count()) {
			$firstImage = $product->padloper_images->first();
			// product image thumb
			$thumb = $product->padloper_images->first()->width(400);
			// --------
			$out .= "<img src='{$thumb->url}' alt='{$product->title}'>";
		}
		$out .= "</div>";
	}
}

echo $out;
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

MORE EXAMPLES TBD