Theme Settings, Extract Templates and Resolvers
Theme settings and custom resolvers allow you to create more portable and flexible themes that are easier to work with without requiring manual configuration steps.
Theme Settings
Fred will automatically include all system settings under the theme’s namespace when building a theme. These settings should be prefixed with fred.theme.theme-name
, where theme-name
is the actual theme name. An example key for a background color in the One Pager demo theme might look like fred.theme.one-pager.bg-color
.
Every theme includes a fred.theme.theme-name.theme_dir
system setting which is created by default. This is for the theme’s web accessible assets such as images and css.
Only the system settings for the specific theme being built are included. Make sure they have the correct prefix and are under the correct namespace, otherwise they will be ignored.
Extract Template
Extract Templates allow you to include specific settings or configuration for Extras used in Themes. They are added in following format:
The packages
is an array of one or more third-party packages to include. The $modx->getService
method is called with the following details:
name
: The name of the package, typically all lowercaseclass
: The name of the service class, often camel casecomponentName
: Optional, defaults to the requiredname
– the name of the directory insidecomponents/
modelName
: Optional, defaults to the requiredname
– the name of the directory insidemodel/
settingPrefix
: Optional, defaults to the requiredname
– the prefix for a system setting (if a custom core path is used)
The vehicles
is a correpsonding array of vehicles that will be exported in the vehicle object format:
object
: A wrapper containing the following attributes:class
: The name of the xPDO classgraph
: The xPDO graphcriteria
: Optional, defaults to[]
– the xPDO criteria used to filter the objects to be extractedgraphCriteria
: Optional, defaults tonull
– the xPDO graph criteria
attributes
: The xPDOTransport attributes
Example for MODX Minify
Example for Client Config
Resolvers
Used by advanced developers, custom PHP resolvers can be executed after a theme is installed as the final step in the install process (or first when uninstalling). An instance of modX
is accessible via $transport->xpdo
. Resolvers can run when a package is installed, upgraded, or uninstalled using the Packager Installer in the MODX Manager.