You are not logged in.
Pages: 1
When a URL is requested BigTree tries to find a matching page and render it's content. If the URL string is an exact match for a page with a basic template assigned, that template will be rendered. If an exact match can not be found, BigTree will start chopping off segments until it does find a match. If it finds a matching page that is assigned a routed template, the left over URL segments are stored in the $commands array and made available in the rendered template. Read more about how BigTree routes pages. If BigTree can't find a basic or routed page that matches, it will render the "_404.php" file from the basic templates folder.
Routed modules are a bit different. Let's say you have a routed template, containing a "default.php" and "details.php" file, assigned to the page "http://www.example.com/products/". The URL "products/" will render the "default.php" file, while "products/details/" will render the "details.php" file. A request like "products/category-name/" could be used to query for, and display products from, a specific category. If the category doesn't actually exist, you may want to display a 404 page for your users:
$productsMod = new SiteProducts;
$categoriesMod = new SiteCategories;
if (isset($commands[0])) {
// $commands[0] = the route of the category
$activeCategory = $categoriesMod->getByRoute($commands[0]);
if (!$activeCategory) {
// Display a 404 since the category doesn't exits
include "../templates/basic[url]/_404.ph[/url]p";
} else {
// Get everything from the specific category
$products = $productsMod->getMatching(array("category"), array($activeCategory["id"]));
}
} else {
// Get everything when no category is defined
$products = $productsMod->getAll();
}
Feel free to style this page any way you want, use a custom layout, go crazy!
Once thing to keep in mind when developing in BigTree is that the page is always executed through the main "index.php" file in the "site" folder (this helps us with the fancy URL rewriting, along with the .htaccess file). This means when including files from different directories, relative file references should be based on the location of the "index.php" file. In the example above, we're including a file from the "basic" template folder in a file from the "routed" template folder, meaning we have to reference the included file with the relative path "../templates/basic/_404.php" (because "templates" is one directory back from "site"). If you are including a file from the same directory, simply reference the file name:
include "_product_search_form.php";
Offline
Pages: 1