mirror of
https://github.com/processwire/processwire.git
synced 2025-08-19 21:11:43 +02:00
Initial commit to new repo (carried over from: https://github.com/ryancramerdesign/ProcessWire/tree/devns)
This commit is contained in:
245
site-default/templates/README.txt
Normal file
245
site-default/templates/README.txt
Normal file
@@ -0,0 +1,245 @@
|
||||
Welcome to the Default Site Profile (Intermediate Edition)
|
||||
==========================================================
|
||||
|
||||
This is a plain text document. If you are currently online with
|
||||
internet access, you will find it much nicer to read an HTML
|
||||
formatted version of this document located at:
|
||||
|
||||
http://processwire.com/docs/tutorials/default-site-profile/
|
||||
|
||||
If you are just getting started with ProcessWire, you might
|
||||
also want to look into the beginner edition of this site profile.
|
||||
|
||||
Need multi-language support? The multi-language version of this
|
||||
default site profile is a good place to start.
|
||||
|
||||
Both the beginner and multi-language versions of this site
|
||||
profile are available as installation options when installing
|
||||
ProcessWire.
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Just getting started with ProcessWire and aren't totally clear on what
|
||||
template files are? The good news is that template files aren't anything
|
||||
other than regular HTML or PHP files, and you can use them however you
|
||||
want! This particular site profile uses a strategy called Delayed Output,
|
||||
but you should use whatever strategy you prefer.
|
||||
|
||||
If you know enough to create an HTML or PHP document, then you already
|
||||
know how to use ProcessWire template files. The only difference is that
|
||||
ProcessWire provides your template files with certain variables that
|
||||
you may choose to use, or not use. Most notable is the $page variable,
|
||||
which contains all the fields of text or other information contained
|
||||
by the page being viewed.
|
||||
|
||||
For instance, $page->title contains the text contained in the Title
|
||||
field of the current page, and $page->body contains the text for the
|
||||
Body field of the current page. You can choose to output those wherever
|
||||
you want. A really simple template file might look like a regular HTML
|
||||
document except for where you want to output the dynamic portions (like
|
||||
title and body). Here's an example:
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title><?= $page->title ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><?= $page->title ?></h1>
|
||||
<?= $page->body ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
That's all that a template file is. Now when we're building something
|
||||
for real, we like to save ourselves as much work as possible and avoid
|
||||
writing the same HTML markup in multiple places. In order to do that
|
||||
we'll usually isolate the repetitive markup into separate files or
|
||||
functions so that we don't have to write it more than once. That's
|
||||
not required of course, but it's a good strategy to save you time and
|
||||
make it easier to maintain your site further down the road.
|
||||
|
||||
Template file strategies
|
||||
========================
|
||||
|
||||
The two most popular strategies for template files are:
|
||||
|
||||
1. Direct Output is the simplest strategy and the one used by the
|
||||
Classic Site Profile. While it doesn't scale as well as other
|
||||
strategies, it is a very good point to start from. If you've
|
||||
ever worked with WordPress templates, chances are you already
|
||||
know how Direct Output works. If you'd rather get started with
|
||||
this strategy, we recommend installing the Classic Site Profile
|
||||
rather than this one. Read more about the Direct Output strategy:
|
||||
http://processwire.com/to/direct-output/
|
||||
|
||||
2. Delayed Output is the strategy used by this site profile. It
|
||||
is also quite simple but involves populating content to
|
||||
placeholder variables rather than outputting directly. As a
|
||||
result it may take a few more seconds to understand than direct
|
||||
output, but the result is more scalable and maintainable. Read
|
||||
more about Delayed Output here:
|
||||
http://processwire.com/to/delayed-output/
|
||||
|
||||
|
||||
How this Default Site Profile works
|
||||
===================================
|
||||
|
||||
This Default Site Profile uses the Delayed Output strategy. Here's
|
||||
how it works:
|
||||
|
||||
1. The initialization file is loaded (_init.php).
|
||||
We use it to define placeholder variables for content regions.
|
||||
|
||||
2. The template file is loaded (i.e. home.php or another).
|
||||
We use it to populate values into the placeholder variables.
|
||||
|
||||
3. The main output file is loaded (_main.php).
|
||||
It is an HTML document that outputs the placeholder variables.
|
||||
|
||||
Below are more details on exactly what takes place and in the three
|
||||
steps outlined above:
|
||||
|
||||
1. The initialization file is loaded (_init.php)
|
||||
---------------------------------------------
|
||||
We define placeholder variables for the regions in our page in
|
||||
the _init.php file. These placeholders can be anything that you
|
||||
like (and in any quantity) and usually depends entirely
|
||||
on the needs of your site design and content.
|
||||
|
||||
In this default site, our needs are simple so we've defined
|
||||
placeholders for just 3 regions on the page. We usually name
|
||||
these regions something consistent with the HTML tag, id or class
|
||||
attribute just for ease of readability, but that's not required.
|
||||
These are the three placeholder variables we've defined in this site:
|
||||
|
||||
$title - The headline or title (we use for <title> and <h1>)
|
||||
$content - The main page content (we use for <div id='content'>)
|
||||
$sidebar - Sidebar content (we use for <div id='sidebar'>)
|
||||
|
||||
The leading "$" is what designates them as placeholder variables.
|
||||
We do this in a file called _init.php. ProcessWire knows to load
|
||||
this _init.php file first, before our actual template file. We
|
||||
define these placeholder variables simply giving each a default
|
||||
value, or by just making them blank. Go ahead and take a look at
|
||||
the _init.php file now if you can. But to summarize, here's how
|
||||
you define a blank placeholder variable:
|
||||
|
||||
$content = '';
|
||||
|
||||
And here's how you define a placeholder variable with an initial
|
||||
or default value:
|
||||
|
||||
$content = "<p>Hello World</p>";
|
||||
|
||||
Here's how we would populate it with a dynamic value from $page:
|
||||
|
||||
$content = $page->body;
|
||||
|
||||
The last thing we want to mention about _init.php is that we
|
||||
might also use it to load any shared functions. You'll see a line
|
||||
in this site's _init.php the includes a file called _func.php.
|
||||
That file simply contains a shared function (used by multiple
|
||||
template files) for generating navigation markup. This part is
|
||||
not so important for now, so come back to it once you understand
|
||||
how everything else works. But the point to understand now is
|
||||
that the _init.php file initializes everything that may be used
|
||||
by the site's template files.
|
||||
|
||||
|
||||
2. The template file is loaded (i.e. home.php or another)
|
||||
------------------------------------------------------
|
||||
Next, ProcessWire loads the template file used by the page being
|
||||
viewed. For example, the homepage uses home.php. We use our
|
||||
template file to populate those placeholder variables we defined
|
||||
in _init.php with the values we want.
|
||||
|
||||
For instance, most often we populate our $content variable with
|
||||
the body copy from the current page:
|
||||
|
||||
$content = $page->body;
|
||||
|
||||
But we might also do something more like append some navigation
|
||||
under the body copy or prepend a photo... the sky is the limit.
|
||||
|
||||
$content = "<img src='/photo.jpg'>" . $page->body;
|
||||
|
||||
Our search.php template file for example, populates $content with
|
||||
a list of search results.
|
||||
|
||||
Because our placeholder variables were already defined in the
|
||||
_init.php file with default values, our template file (like
|
||||
home.php or basic-page.php) need only focus on populating the
|
||||
placeholder variables that you want to modify. It does not
|
||||
even need to mention those placeholder variables that it doesn't
|
||||
need or doesn't need to change.
|
||||
|
||||
|
||||
3. Everything gets output by _main.php
|
||||
-----------------------------------
|
||||
After ProcessWire has loaded our template file (i.e. home.php) it
|
||||
then knows to load the _main.php file last. In the case of this
|
||||
site, our _main.php file is an entire HTML document that outputs
|
||||
our placeholder variables in the regions where they should appear.
|
||||
For example, the $content variable gets output in #content <div>
|
||||
like this:
|
||||
|
||||
<div id='content'>
|
||||
<?= $content ?>
|
||||
</div>
|
||||
|
||||
Please go ahead and take a look at the _main.php file for context.
|
||||
|
||||
Note that our _main.php uses "<?php echo $content; ?>" style,
|
||||
rather than "<?= $content ?>" style, like shown above, just in
|
||||
case you happen to be running an older version of PHP. But more
|
||||
than likely you can use the shorter syntax when preferred, as the
|
||||
two are functionally equivalent.
|
||||
|
||||
|
||||
More template file resources
|
||||
============================
|
||||
|
||||
- How do template files work?
|
||||
https://processwire.com/api/templates/
|
||||
Official documentation on template files.
|
||||
|
||||
- API variables
|
||||
https://processwire.com/api/variables/
|
||||
We mentioned $page above, but here are all the other API variables
|
||||
your template file can make use of.
|
||||
|
||||
- API cheatsheet
|
||||
http://cheatsheet.processwire.com/
|
||||
Once you've got the basics down, this cheatsheet is invaluable in
|
||||
describing all the properties and functions available to your
|
||||
template files.
|
||||
|
||||
|
||||
Tutorials that help with template files
|
||||
=======================================
|
||||
|
||||
- Hello Worlds Tutoral, by Ryan Cramer
|
||||
http://processwire.com/docs/tutorials/hello-worlds/
|
||||
The Hello Worlds tutorial gently introduces ProcessWire and template
|
||||
files, starting from a blank slate.
|
||||
|
||||
- "But what if I don't know how to code?", by Joss Sanglier
|
||||
http://processwire.com/docs/tutorials/but-what-if-i-dont-know-how-to-code/
|
||||
This particular series of tutorials will not only introduce you to
|
||||
ProcessWire, but step by step, will give you those small bits of coding
|
||||
knowledge that will get you going and open up this amazing world of a
|
||||
Content Management Framework.
|
||||
|
||||
- Installing a CSS Framework, by Joss Sanglier
|
||||
http://processwire.com/docs/tutorials/installing-a-css-framework/
|
||||
A quick demonstration about how easy it is to use one of the many CSS
|
||||
frameworks available to designers.
|
||||
|
||||
- How to structure your template files, by Ryan Cramer
|
||||
http://processwire.com/docs/tutorials/how-to-structure-your-template-files/
|
||||
This tutorial contrasts and compares the direct output and delayed
|
||||
output strategies and more. It is a very good introduction to using
|
||||
ProcessWire template files.
|
||||
|
||||
|
||||
119
site-default/templates/_func.php
Normal file
119
site-default/templates/_func.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* /site/templates/_func.php
|
||||
*
|
||||
* Example of shared functions used by template files
|
||||
*
|
||||
* This file is currently included by _init.php
|
||||
*
|
||||
* For more information see README.txt
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Given a group of pages, render a simple <ul> navigation
|
||||
*
|
||||
* This is here to demonstrate an example of a simple shared function.
|
||||
* Usage is completely optional.
|
||||
*
|
||||
* @param PageArray $items
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
function renderNav(PageArray $items) {
|
||||
|
||||
// $out is where we store the markup we are creating in this function
|
||||
$out = '';
|
||||
|
||||
// cycle through all the items
|
||||
foreach($items as $item) {
|
||||
|
||||
// render markup for each navigation item as an <li>
|
||||
if($item->id == wire('page')->id) {
|
||||
// if current item is the same as the page being viewed, add a "current" class to it
|
||||
$out .= "<li class='current'>";
|
||||
} else {
|
||||
// otherwise just a regular list item
|
||||
$out .= "<li>";
|
||||
}
|
||||
|
||||
// markup for the link
|
||||
$out .= "<a href='$item->url'>$item->title</a> ";
|
||||
|
||||
// if the item has summary text, include that too
|
||||
if($item->summary) $out .= "<div class='summary'>$item->summary</div>";
|
||||
|
||||
// close the list item
|
||||
$out .= "</li>";
|
||||
}
|
||||
|
||||
// if output was generated above, wrap it in a <ul>
|
||||
if($out) $out = "<ul class='nav'>$out</ul>\n";
|
||||
|
||||
// return the markup we generated above
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given a group of pages, render a <ul> navigation tree
|
||||
*
|
||||
* This is here to demonstrate an example of a more intermediate level
|
||||
* shared function and usage is completely optional. This is very similar to
|
||||
* the renderNav() function above except that it can output more than one
|
||||
* level of navigation (recursively) and can include other fields in the output.
|
||||
*
|
||||
* @param array|PageArray $items
|
||||
* @param int $maxDepth How many levels of navigation below current should it go?
|
||||
* @param string $fieldNames Any extra field names to display (separate multiple fields with a space)
|
||||
* @param string $class CSS class name for containing <ul>
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
function renderNavTree($items, $maxDepth = 0, $fieldNames = '', $class = 'nav') {
|
||||
|
||||
// if we were given a single Page rather than a group of them, we'll pretend they
|
||||
// gave us a group of them (a group/array of 1)
|
||||
if($items instanceof Page) $items = array($items);
|
||||
|
||||
// $out is where we store the markup we are creating in this function
|
||||
$out = '';
|
||||
|
||||
// cycle through all the items
|
||||
foreach($items as $item) {
|
||||
|
||||
// markup for the list item...
|
||||
// if current item is the same as the page being viewed, add a "current" class to it
|
||||
$out .= $item->id == wire('page')->id ? "<li class='current'>" : "<li>";
|
||||
|
||||
// markup for the link
|
||||
$out .= "<a href='$item->url'>$item->title</a>";
|
||||
|
||||
// if there are extra field names specified, render markup for each one in a <div>
|
||||
// having a class name the same as the field name
|
||||
if($fieldNames) foreach(explode(' ', $fieldNames) as $fieldName) {
|
||||
$value = $item->get($fieldName);
|
||||
if($value) $out .= " <div class='$fieldName'>$value</div>";
|
||||
}
|
||||
|
||||
// if the item has children and we're allowed to output tree navigation (maxDepth)
|
||||
// then call this same function again for the item's children
|
||||
if($item->hasChildren() && $maxDepth) {
|
||||
if($class == 'nav') $class = 'nav nav-tree';
|
||||
$out .= renderNavTree($item->children, $maxDepth-1, $fieldNames, $class);
|
||||
}
|
||||
|
||||
// close the list item
|
||||
$out .= "</li>";
|
||||
}
|
||||
|
||||
// if output was generated above, wrap it in a <ul>
|
||||
if($out) $out = "<ul class='$class'>$out</ul>\n";
|
||||
|
||||
// return the markup we generated above
|
||||
return $out;
|
||||
}
|
||||
|
||||
40
site-default/templates/_init.php
Normal file
40
site-default/templates/_init.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* Initialize variables output in _main.php
|
||||
*
|
||||
* Values populated to these may be changed as desired by each template file.
|
||||
* You can setup as many such variables as you'd like.
|
||||
*
|
||||
* This file is automatically prepended to all template files as a result of:
|
||||
* $config->prependTemplateFile = '_init.php'; in /site/config.php.
|
||||
*
|
||||
* If you want to disable this automatic inclusion for any given template,
|
||||
* go in your admin to Setup > Templates > [some-template] and click on the
|
||||
* "Files" tab. Check the box to "Disable automatic prepend file".
|
||||
*
|
||||
*/
|
||||
|
||||
// Variables for regions we will populate in _main.php. Here we also assign
|
||||
// default values for each of them.
|
||||
$title = $page->get('headline|title'); // headline if available, otherwise title
|
||||
$content = $page->body;
|
||||
$sidebar = $page->sidebar;
|
||||
|
||||
|
||||
// We refer to our homepage a few times in our site, so we preload a copy
|
||||
// here in a $homepage variable for convenience.
|
||||
$homepage = $pages->get('/');
|
||||
|
||||
|
||||
// Include shared functions (if any)
|
||||
include_once("./_func.php");
|
||||
|
||||
|
||||
// What happens after this?
|
||||
// ------------------------
|
||||
// 1. ProcessWire loads your page's template file (i.e. basic-page.php).
|
||||
// 2. ProcessWire loads the _main.php file
|
||||
//
|
||||
// See the README.txt file for more information.
|
||||
|
||||
110
site-default/templates/_main.php
Normal file
110
site-default/templates/_main.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* _main.php
|
||||
* Main markup file
|
||||
*
|
||||
* This file contains all the main markup for the site and outputs the regions
|
||||
* defined in the initialization (_init.php) file. These regions include:
|
||||
*
|
||||
* $title: The page title/headline
|
||||
* $content: The markup that appears in the main content/body copy column
|
||||
* $sidebar: The markup that appears in the sidebar column
|
||||
*
|
||||
* Of course, you can add as many regions as you like, or choose not to use
|
||||
* them at all! This _init.php > [template].php > _main.php scheme is just
|
||||
* the methodology we chose to use in this particular site profile, and as you
|
||||
* dig deeper, you'll find many others ways to do the same thing.
|
||||
*
|
||||
* This file is automatically appended to all template files as a result of
|
||||
* $config->appendTemplateFile = '_main.php'; in /site/config.php.
|
||||
*
|
||||
* In any given template file, if you do not want this main markup file
|
||||
* included, go in your admin to Setup > Templates > [some-template] > and
|
||||
* click on the "Files" tab. Check the box to "Disable automatic append of
|
||||
* file _main.php". You would do this if you wanted to echo markup directly
|
||||
* from your template file or if you were using a template file for some other
|
||||
* kind of output like an RSS feed or sitemap.xml, for example.
|
||||
*
|
||||
* See the README.txt file for more information.
|
||||
*
|
||||
*/
|
||||
?><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title><?php echo $title; ?></title>
|
||||
<meta name="description" content="<?php echo $page->summary; ?>" />
|
||||
<link href='//fonts.googleapis.com/css?family=Lusitana:400,700|Quattrocento:400,700' rel='stylesheet' type='text/css' />
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
|
||||
</head>
|
||||
<body class="<?php if($sidebar) echo "has-sidebar "; ?>">
|
||||
|
||||
<!-- top navigation -->
|
||||
<ul class='topnav'><?php
|
||||
// top navigation consists of homepage and its visible children
|
||||
foreach($homepage->and($homepage->children) as $item) {
|
||||
if($item->id == $page->rootParent->id) {
|
||||
echo "<li class='current'>";
|
||||
} else {
|
||||
echo "<li>";
|
||||
}
|
||||
echo "<a href='$item->url'>$item->title</a></li>";
|
||||
}
|
||||
|
||||
// output an "Edit" link if this page happens to be editable by the current user
|
||||
if($page->editable()) echo "<li class='edit'><a href='$page->editUrl'>Edit</a></li>";
|
||||
?></ul>
|
||||
|
||||
<!-- search form-->
|
||||
<form class='search' action='<?php echo $pages->get('template=search')->url; ?>' method='get'>
|
||||
<input type='text' name='q' placeholder='Search' value='<?php echo $sanitizer->entities($input->whitelist('q')); ?>' />
|
||||
<button type='submit' name='submit'>Search</button>
|
||||
</form>
|
||||
|
||||
<!-- breadcrumbs -->
|
||||
<div class='breadcrumbs'><?php
|
||||
// breadcrumbs are the current page's parents
|
||||
foreach($page->parents() as $item) {
|
||||
echo "<span><a href='$item->url'>$item->title</a></span> ";
|
||||
}
|
||||
// optionally output the current page as the last item
|
||||
echo "<span>$page->title</span> ";
|
||||
?></div>
|
||||
|
||||
<div id='main'>
|
||||
|
||||
<!-- main content -->
|
||||
<div id='content'>
|
||||
<h1><?php echo $title; ?></h1>
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
|
||||
<!-- sidebar content -->
|
||||
<?php if($sidebar): ?>
|
||||
<div id='sidebar'>
|
||||
<?php echo $sidebar; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- footer -->
|
||||
<footer id='footer'>
|
||||
<p>
|
||||
Powered by <a href='http://processwire.com'>ProcessWire CMS</a> /
|
||||
<?php
|
||||
if($user->isLoggedin()) {
|
||||
// if user is logged in, show a logout link
|
||||
echo "<a href='{$config->urls->admin}login/logout/'>Logout ($user->name)</a>";
|
||||
} else {
|
||||
// if user not logged in, show a login link
|
||||
echo "<a href='{$config->urls->admin}'>Admin Login</a>";
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
15
site-default/templates/admin.php
Normal file
15
site-default/templates/admin.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* Admin template just loads the admin application controller,
|
||||
* and admin is just an application built on top of ProcessWire.
|
||||
*
|
||||
* This demonstrates how you can use ProcessWire as a front-end
|
||||
* to another application.
|
||||
*
|
||||
* Feel free to hook admin-specific functionality from this file,
|
||||
* but remember to leave the require() statement below at the end.
|
||||
*
|
||||
*/
|
||||
|
||||
require($config->paths->adminTemplates . 'controller.php');
|
||||
20
site-default/templates/basic-page.php
Normal file
20
site-default/templates/basic-page.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
// basic-page.php template file
|
||||
// See README.txt for more information
|
||||
|
||||
// Primary content is the page's body copy
|
||||
$content = $page->body;
|
||||
|
||||
// If the page has children, then render navigation to them under the body.
|
||||
// See the _func.php for the renderNav example function.
|
||||
if($page->hasChildren) {
|
||||
$content .= renderNav($page->children);
|
||||
}
|
||||
|
||||
// if the rootParent (section) page has more than 1 child, then render
|
||||
// section navigation in the sidebar
|
||||
if($page->rootParent->hasChildren > 1) {
|
||||
$sidebar = renderNavTree($page->rootParent, 3) . $page->sidebar;
|
||||
}
|
||||
|
||||
11
site-default/templates/errors/500.html
Normal file
11
site-default/templates/errors/500.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>500 Internal Server Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Internal Server Error</h1>
|
||||
<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p>
|
||||
<p>{message}</p>
|
||||
</body>
|
||||
</html>
|
||||
21
site-default/templates/errors/README.txt
Normal file
21
site-default/templates/errors/README.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
When a fatal error occurs, ProcessWire displays the message:
|
||||
|
||||
"Unable to complete this request due to an error."
|
||||
|
||||
The message is intentionally vague for security purposes.
|
||||
Details will be logged to /site/assets/logs/errors.txt.
|
||||
|
||||
When present in this directory, the file 500.html will be
|
||||
displayed instead of the generic error message above. Feel
|
||||
free to modify this file to show whatever you would like.
|
||||
Please note the following:
|
||||
|
||||
* 500.html is plain HTML and has no PHP or API access.
|
||||
|
||||
* You may enter the tag {message} and ProcessWire will
|
||||
replace this with additional details when applicable.
|
||||
When not applicable, it will make it blank.
|
||||
|
||||
* If you are logged in as an admin, ProcessWire will
|
||||
give you a detailed error message rather than 500.html.
|
||||
|
||||
25
site-default/templates/home.php
Normal file
25
site-default/templates/home.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
// home.php (homepage) template file.
|
||||
// See README.txt for more information
|
||||
|
||||
// Primary content is the page body copy and navigation to children.
|
||||
// See the _func.php file for the renderNav() function example
|
||||
$content = $page->body . renderNav($page->children);
|
||||
|
||||
// if there are images, lets choose one to output in the sidebar
|
||||
if(count($page->images)) {
|
||||
// if the page has images on it, grab one of them randomly...
|
||||
$image = $page->images->getRandom();
|
||||
// resize it to 400 pixels wide
|
||||
$image = $image->width(400);
|
||||
// output the image at the top of the sidebar...
|
||||
$sidebar = "<img src='$image->url' alt='$image->description' />";
|
||||
// ...and append sidebar text under the image
|
||||
$sidebar .= $page->sidebar;
|
||||
} else {
|
||||
// no images...
|
||||
// append sidebar text if the page has it
|
||||
$sidebar = $page->sidebar;
|
||||
}
|
||||
|
||||
3
site-default/templates/scripts/main.js
Normal file
3
site-default/templates/scripts/main.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// Well hello there. Looks like we don't have any Javascript.
|
||||
// Maybe you could help a friend out and put some in here?
|
||||
// Or at least, when ready, this might be a good place for it.
|
||||
51
site-default/templates/search.php
Normal file
51
site-default/templates/search.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
// search.php template file
|
||||
// See README.txt for more information.
|
||||
|
||||
// look for a GET variable named 'q' and sanitize it
|
||||
$q = $sanitizer->text($input->get->q);
|
||||
|
||||
// did $q have anything in it?
|
||||
if($q) {
|
||||
// Send our sanitized query 'q' variable to the whitelist where it will be
|
||||
// picked up and echoed in the search box by _main.php file. Now we could just use
|
||||
// another variable initialized in _init.php for this, but it's a best practice
|
||||
// to use this whitelist since it can be read by other modules. That becomes
|
||||
// valuable when it comes to things like pagination.
|
||||
$input->whitelist('q', $q);
|
||||
|
||||
// Sanitize for placement within a selector string. This is important for any
|
||||
// values that you plan to bundle in a selector string like we are doing here.
|
||||
$q = $sanitizer->selectorValue($q);
|
||||
|
||||
// Search the title and body fields for our query text.
|
||||
// Limit the results to 50 pages.
|
||||
$selector = "title|body~=$q, limit=50";
|
||||
|
||||
// If user has access to admin pages, lets exclude them from the search results.
|
||||
// Note that 2 is the ID of the admin page, so this excludes all results that have
|
||||
// that page as one of the parents/ancestors. This isn't necessary if the user
|
||||
// doesn't have access to view admin pages. So it's not technically necessary to
|
||||
// have this here, but we thought it might be a good way to introduce has_parent.
|
||||
if($user->isLoggedin()) $selector .= ", has_parent!=2";
|
||||
|
||||
// Find pages that match the selector
|
||||
$matches = $pages->find($selector);
|
||||
|
||||
// did we find any matches?
|
||||
if($matches->count) {
|
||||
// yes we did
|
||||
$content = "<h2>Found $matches->count pages matching your query:</h2>";
|
||||
// we'll use our renderNav function (in _func.php) to render the navigation
|
||||
$content .= renderNav($matches);
|
||||
} else {
|
||||
// we didn't find any
|
||||
$content = "<h2>Sorry, no results were found.</h2>";
|
||||
}
|
||||
|
||||
} else {
|
||||
// no search terms provided
|
||||
$content = "<h2>Please enter a search term in the search box (upper right corner)</h2>";
|
||||
}
|
||||
|
||||
9
site-default/templates/sitemap.php
Normal file
9
site-default/templates/sitemap.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
// sitemap.php template file
|
||||
// Generate navigation that descends up to 4 levels into the tree.
|
||||
// See the _func.php for the renderNav() function definition.
|
||||
// See the README.txt for more information.
|
||||
|
||||
$content = renderNavTree($homepage, 4);
|
||||
|
||||
299
site-default/templates/styles/main.css
Normal file
299
site-default/templates/styles/main.css
Normal file
@@ -0,0 +1,299 @@
|
||||
/**
|
||||
* main.css
|
||||
*
|
||||
* 1. General HTML tags
|
||||
* 2. Masthead area
|
||||
* 3. Main content and sidebar
|
||||
* 4. Footer
|
||||
* 5. Media queries for responsive layout
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* 1. General HTML tags
|
||||
*
|
||||
*/
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 5%;
|
||||
max-width: 1600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
body, td, input[type=text], textarea {
|
||||
font-family: 'Quattrocento', serif;
|
||||
font-size: 105%;
|
||||
line-height: 1.8em;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3 {
|
||||
border-top: 1px solid #eee;
|
||||
padding-top: 1em;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
a:hover,
|
||||
.nav a:hover {
|
||||
color: #000;
|
||||
border-color: #aaa;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin-left: 0;
|
||||
padding-left: 1.5em;
|
||||
padding-right: 2em;
|
||||
border-left: 4px solid #ddd;
|
||||
font-style: italic;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
background: #eee;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
padding: 1em;
|
||||
border-left: 4px solid #ddd;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* 2. Masthead area
|
||||
*
|
||||
*/
|
||||
|
||||
.topnav, .topnav li {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.topnav li {
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.topnav a {
|
||||
padding: 0.25em 0.5em;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
background: #eee;
|
||||
color: #333;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
.topnav a:hover {
|
||||
background: #ddd;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.topnav li.current a {
|
||||
background: #ddd;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.topnav li.edit a {
|
||||
background: none;
|
||||
}
|
||||
|
||||
|
||||
form.search {
|
||||
float: right;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
form.search input {
|
||||
margin: 0;
|
||||
padding: 0.25em 0.5em;
|
||||
border: 1px solid #ccc;
|
||||
width: 100%;
|
||||
}
|
||||
form.search button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.breadcrumbs {
|
||||
clear: both;
|
||||
padding-top: 1em;
|
||||
}
|
||||
.breadcrumbs span:after {
|
||||
content: ">";
|
||||
color: #999;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.25em;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* 3. Main content and sidebar
|
||||
*
|
||||
*/
|
||||
|
||||
#main {
|
||||
border-top: 1px solid #eee;
|
||||
padding-top: 1em;
|
||||
margin-top: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#content {
|
||||
width: 85%;
|
||||
}
|
||||
|
||||
#content, #sidebar {
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
body.has-sidebar #content {
|
||||
width: 65%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
body.has-sidebar #sidebar {
|
||||
width: 35%;
|
||||
padding-left: 5%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.nav {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.nav .nav {
|
||||
padding-left: 1.5em;
|
||||
list-style: disc;
|
||||
}
|
||||
.nav li {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.nav-tree li {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.nav a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.nav-tree li a {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.nav .current > a {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.align_left {
|
||||
/* for images placed in rich text editor */
|
||||
float: left;
|
||||
margin: 0 1em 0.5em 0;
|
||||
position: relative;
|
||||
top: 0.5em;
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
.align_right {
|
||||
/* for images placed in rich text editor */
|
||||
float: right;
|
||||
margin: 0 0 0.5em 1em;
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
.align_center {
|
||||
/* for images placed in rich text editor */
|
||||
display: block;
|
||||
margin: 1em auto;
|
||||
position: relative;
|
||||
top: 0.5em;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: table;
|
||||
width: 1px;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
figure img {
|
||||
display: table-row;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
figure figcaption {
|
||||
display: table-row;
|
||||
font-size: smaller;
|
||||
color: #777;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* 4. Footer
|
||||
*
|
||||
*/
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
border-top: 1px solid #eee;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* 5. Media queries for responsive layout
|
||||
*
|
||||
*/
|
||||
|
||||
@media only screen and (max-width: 767px) {
|
||||
/* mobile layout */
|
||||
|
||||
body, td, textarea {
|
||||
font-size: 100%;
|
||||
}
|
||||
body.has-sidebar #content,
|
||||
body.has-sidebar #sidebar {
|
||||
float: none;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
form.search {
|
||||
float: none;
|
||||
width: 100%;
|
||||
}
|
||||
#content {
|
||||
width: 100%;
|
||||
}
|
||||
#sidebar {
|
||||
border-top: 1px solid #eee;
|
||||
padding-top: 1em;
|
||||
}
|
||||
.align_left, .align_right, .align_center {
|
||||
display: block;
|
||||
float: none;
|
||||
margin: 1em auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 1200px) {
|
||||
/* extra-wide desktop layout */
|
||||
|
||||
body, td, textarea {
|
||||
font-size: 115%;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user