The website is built on the content management system, which is a PHP based, headless, open source CMS with PHP/HTML templates. This document is meant to be only a quick reference for whoever is already familiar with the VMGroup site structure. It assumes prior familiarity from the initial onboarding session. It only touches on important strategies for a quick understanding of where the markup comes from.
Templating language
Template files live in the /site/templates/ folder on the web server and correspond to the relevant template name (content type) in Setup > Templates in the admin backend.
Output strategy
The main site structure, including the <head> section is defined in _main.php.
The site uses a type of delayed output strategy, called , where page templates can add/modify/remove markup from regions defined in _main.php. The order in which template files are executed for page templates is as follows.
Prepending _init.php and appending _main.php are defined in /sites/config.php as defaults.
/partials/_init.php (variables for template files; includes _func.php) /partials/_func.php (helper functions such as truncating text, or navigation) page-template.php (e.g. home.php or basic-page.php, overriding or adding content to sections) _main.php (the main page markup) ProcessWire uses vanilla PHP templates, without any further abstraction. Unlike MVP models, this means you mix your PHP logic with the HTML output, unless you setup a different architecture. It is possible to use ProcessWire with Twig or other templating languages and setup controllers and view files. There’s existing community support for it but it is extra work.
API - Displaying field content in templates
ProcessWire has a very powerful javascript-inspired API. is a good place to start. Outputting a field in its basic form is as simple as <?php echo $page->title ?>
Multi-value fields can be typically accessed by a simple PHP foreach loop:
// Image galleries don't need a plugin, just a few lines of code
foreach ($page->images as $image){
echo "<img src='{$image->size(800,600)->webp->url}' alt='{$image->description}'>";
}
Selectors - Page Arrays
ProcessWire’s API also makes it very easy to query content based on conditions.
$pages enables loading and manipulation of Page objects, to and from the database, without the need to directly running database queries. You then have methods such as find or get to retrieve a page or a list of pages as a PageArray that you can later loop through.
Examples:
// Returns the page with Home as a title, or null if nothing is found
$single_page = $pages->get("title=home");
// Returns all pages with post as their content type, or empty array if non found
$page_list = $pages->find("template=post");
// You can then use them in your template after verifying the results:
if ($page_list && count($page_list) > 0) {
foreach($page_list as $p) {
// write your own markup
}
}
Templates (Content types)
ProcessWire is based on custom fields and custom content types (called templates in the backend).
Each template needs a corresponding PHP template file in the /site/templates/ folder in order to be viewed on the website, ProcessWire doesn’t generate or assume any markup.
Fields
The CMS also comes with a large number of core field types such as text, textarea, page reference, file etc… and many more are available as community modules.
You define your own fields, which you can add to templates. You can reuse fields across templates.
Resources