-
Notifications
You must be signed in to change notification settings - Fork 9
Configuration
Joomlatools Pages gives you a lot of flexibility to customize how it builds your pages. These options can be specified in a /config.php
file placed in your root directory. The config file defines settings for caching, metadata, and more...
The first step is to create a file named config.php
in the root of your pages directory. In this file, place the following:
<?php
return array(
// Your configuration settings go here
);
?>
Now that you have created your configuration file, you can go ahead and add the settings you need.
<?php
return array(
//Http Caching
'http_cache' => false,
'http_cache_path' => JPATH_ROOT.'/joomlatools-pages/cache',
'http_cache_time' => false,
'http_cache_time_browser' => null,
'http_cache_validation' => true,
'http_cache_control' => array(),
'http_cache_control_private' => array('private', 'no-cache'),
//Static caching
'http_static_cache' => getenv('PAGES_STATIC_ROOT') ? true : false,
'http_static_cache_path' => getenv('PAGES_STATIC_ROOT') ? getenv('PAGES_STATIC_ROOT') : false,
//Page caching
'page_cache' => true,
'page_cache_path' => JPATH_ROOT.'/joomlatools-pages/cache/pages',
'data_cache_validation' => true,
//Data caching
'data_cache' => true,
'data_cache_path' => JPATH_ROOT.'/joomlatools-pages/cache/data',
'data_cache_validation' => true,
'data_namespaces' => array(),
//Remote caching
'http_resource_cache' => JFactory::getConfig()->get('caching'),
'http_resource_cache_path' => JPATH_ROOT.'/joomlatools-pages/cache/resources',
'http_resource_cache_debug' => JDEBUG ? false : true,
//Template caching
'template_cache' => JDEBUG ? false : true,
'template_cache_path' => JPATH_ROOT.'/joomlatools-pages/cache/templates',
'template_cache_validation' => true,
//Named Collections
'collections' => [
'pages' => [
'state' => ['level' => 1, 'visible' => true]
],
'repositories' => [
'source' => 'webservice?url=https://api.github.com/path/to/repo',
]
],
//Page configuration
'page' => [
'metadata' => [
'og:site_name' => 'My Site',
'og:image' => '/images/layout/card.jpg',
'twitter:site' => '@mysite',
'twitter:card' => 'summary_large_image',
],
],
//Redirects
'redirects' => [
'/path/to/foo' => '/path/to/other/foo',
'/path/to/bar' => 'http://example.com/path/to/bar'
],
//Sites
'sites' => [
'[*]' => JPATH_ROOT.'/sites/default'
],
//Template
'template' => 'protostar',
'template_config' => ['fluidContainer' => 1],
//Composer path
'composer_path' => $config->site_path.'/vendor',
);
This setting allows you to enable or disable the http cache. By default, the cache is disabled if Joomla debug is enabled.
This setting defines the path used to store the http cache. The filename is composed as follows document_[key]
The key is then calculated as follows crc32($key.PHP_VERSION)
;
This setting allows you to define the max-age
cache directive. This accepts values in seconds. The default cache time is set to 15 minutes.
The max-age directive states the maximum amount of time in seconds that fetched responses are allowed to be used again (from the time when a request is made). For instance, “max-age=900” indicates that an asset can be reused (remains in the browser cache) for the next 900 seconds.
This setting allows you to define the s-maxage
cache directive. This accepts values in seconds. The default proxy cache time is set to 120 minutes or 2 hours.
The “s-” stands for shared as in “shared cache”. This directive is explicitly for CDNs among other intermediary caches. This directive overrides the max-age directive and expires header field when present.
See also: Caching > Http
The data cache auto-refreshes itself if a data file is modified, or if the cache has expired.
This setting allows you to enable or disable the data cache. By default, the cache is disabled if Joomla debug is enabled.
This setting allows you to define the cache lifetime. This accepts values in seconds. The default cache time is set to 1 day.
This setting defines the path used to store the data cache. The filename is composed as follows data_[key]
The key is then calculated as follows crc32($key.PHP_VERSION)
;
See also: Caching > Object
The page cache auto-refreshes itself if a page is modified, or of the cache has expired.
This setting allows you to enable or disable the page cache. By default, the cache is disabled if Joomla debug is enabled.
This setting allows you to define the cache lifetime. This accepts values in seconds. The default cache time is set to 1 day.
This setting defines the path used to store the page cache. The filename is composed as follows page_[key]
The key is then calculated as follows crc32($key.PHP_VERSION)
See also: Caching > Object
The remote cache cannot auto-refresh itself, the cache will only be refreshed if it has expired.
This setting allows you to enable or disable the remote cache. By default, the cache is disabled if Joomla debug is enabled.
This setting allows you to define the cache lifetime. This accepts values in seconds. The default cache time is set to 1 day.
This setting defines the path used to store the remote cache. The filename is composed as follows remote_[key]
The key is then calculated as follows crc32($key.PHP_VERSION)
;
See also: Caching > Object
The template cache auto-refreshes itself if a template file was modified. It doesn't have a setting to define the cache lifetime.
This setting allows you to enable or disable the template cache. By default, the cache is disabled if Joomla debug is enabled.
This option defines the path used to store the template cache. The filename is composed as follows template_[key]
The key is then calculated as follows crc32($key.PHP_VERSION)
;
See also: Caching > Template
To use the Joomla cache manager the different cache paths need to be configured to make use of the Joomla cache location: JPATH_CACHE
return array(
'page_cache_path' => JPATH_CACHE.'/pages',
'http_cache_path' => JPATH_CACHE.'/pages_documents',
'data_cache_path' => JPATH_CACHE.'/pages_data',
'remote_cache_path' => JPATH_CACHE.'/pages_remote',
'template_cache_path' => JPATH_CACHE.'/pages_templates',
);
The metadata
setting allows you to define default page metadata. You can, for example, use this to set your Opengraph defaults and, if you are using Facebook, insert the Facebook pixel for each page.
'metadata' => [
'og:site_name' => 'My Site',
'og:image' => '/images/layout/card.jpg',
'twitter:site' => '@mysite',
'twitter:card' => 'summary_large_image',
'fb:pages' => '12341245437655'
]
);
See also: Page > Metadata > Opengraph
The collections
setting allows you to define named collections which you can then access anywhere in your code using the collection([name])
methods.
'collections' => [
'pages' => [
'state' => ['level' => 1, 'visible' => true]
],
'repositories' => [
'model' => 'webservice?url=https://api.github.com/path/to/repo',
]
],
For example, to retrieve the stargazer count for each Github repository you could do
<? foreach(collection('respositories') as $respository): ?>
<?= $repository->stargazers_count ?>
<? endforeach ?>
See also: Page > Collection
Redirects can be configured using redirects
setting and uses the format: array('/path' => '/target')
. The target can be both an internal path, or an external URL.
If the redirect is an internal path it will use a 307 temporary redirect, if the redirect is an external URL it will use a 301 permanent redirect.
'redirects' =>
'/path/to/foo' => '/path/to/other/foo' //internal
'/path/to/bar' => 'http://example.com/path/to/bar' //external
]
See also: URLs and Linking > Redirects
The sites
setting allows to configure your Pages root directory location /joomlatools-pages
and add additional sites. It uses the format: array('route' => '/directory')
.
To change the default root directory you can add the following to your configuration:
'sites' => [
'[*]' => JPATH_ROOT.'/sites/default'
]
See also: Advanced > Multisite
The template
setting defines the Joomla template instead of relying on the configured template in Joomla.
'template' => 'protostar'
The template_config
setting sets the Joomla template configuration. If no template is defined the config will be applied to the active Joomla template.
'template_config' => ['fluidContainer' => 1];
``
Got a question or need help? We have a forum on Github Discussions where you can get in touch with us.