Skip to content

Configuration

What to set after installing, and what already works without you.

Routing

One setting decides how much of the request PageBlocks handles:

pageblocks_routingWhat happens
Disabled (off)The component does not touch routing. MODX resolves every URL itself.
Route Only (routes)Your routes are matched; anything unmatched falls through to MODX.
Full API (full)PageBlocks owns the request.

off is the default — an installation changes nothing about how the site answers until you say so.

The rest of the settings have working defaults; see System settings for the full list.

Server

  • Apache — rename ht.access to .htaccess
  • Nginx — set up the rewrite rules, since nginx does not read .htaccess

Without this, every address except the front page is a 404: the web server looks for a directory that is not there instead of handing the URL to index.php.

Pages already work

The app layer ships two routes for ordinary MODX resources, in core/App/routes/web.php:

php
<?php

use Boshnik\PageBlocks\Facades\Route;

Route::get('/{alias?}', 'ResourceController@index');
Route::get('/{context}/{alias?}', 'ResourceController@context')->where('context', '[a-z]{2}');

The first opens any resource by its alias. The second is the multilingual case: a two-letter prefix is treated as a language and the rest as the alias — which is why an address like /en/about works as soon as a second language exists, without adding a route. See Languages.

ResourceController finds the resource, picks its template and renders the page. Nothing else is required to serve a normal site.

These live in the site layer, so they are yours

core/App/routes/ belongs to the site, not to the component — an upgrade will not overwrite it. Override either route, or delete them and take the request over entirely.

Route files are read in alphabetical order

Everything in core/App/routes/ is picked up by a glob, sorted by filename. web.php sorts near the end, and that is deliberate: its /{alias?} catches anything not claimed earlier, so a file that sorts after it never gets a chance.

Name a file for a specific section — product.php, catalog.php — and it is matched first. This is not cosmetic; it is the whole ordering mechanism.

© PageBlocks 2019-present