Template Basics
Templates are located inside the templates
directory. You can set a global template under admin/edit/settings
and customize a template for each content.
Getting started
We highly recommend the skeleton
template to start on a solid foundation. You can utilize the preview
module to observe your components while developing.
Hidden feature
Override the current settings by temporary switching between installed templates:
domain.com/article.{template-name}
domain.com/?p=article&t={template-name}Edit on GitHub
Template Partials
Index
Required file index.phtml
contains your basic layout.
<!DOCTYPE html> <html> <!-- head --> <head> ... </head> <!-- body --> <body> <!-- header --> <!-- main --> <!-- footer --> <!-- script --> </body> </html>
Head
File head.phtml
contains <base>
, <title>
, <meta>
, <link>
and <script>
elements for your <head>
tag.
<!-- base --> <base /> <!-- title --> <title> ... </title> <!-- meta --> <meta /> <!-- link --> <link /> <!-- head script --> <script> ... </script>
Header
File header.phtml
contains elements for your structural <header>
tag.
<!-- header --> <header> ... </header>
Main
File main.phtml
contains elements for your structural <main>
tag.
<!-- main --> <main> <!-- error --> <!-- content --> <!-- sidebar --> </main>
Error
File error.phtml
contains error related elements for your structural <article>
tag.
<!-- error --> <article> ... </article>
Content
File content.phtml
contains content related elements for your structural <article>
tag.
<!-- content --> <article> ... </article>
Sidebar
File sidebar.phtml
contains elements for your structural <aside>
tag.
<!-- sidebar --> <aside> ... </aside>
Footer
File footer.phtml
contains elements for your structural <footer>
tag.
<!-- footer --> <footer> ... </footer>
Script
File script.phtml
contains <script>
elements before the body
tag.
<!-- foot script --> <script> ... </script>Edit on GitHub
Template Tags
Namespace
Define the template namespace at the top:
<?php namespace Redaxscript\Template; ?>
Partial
Include a single or multiple PHTML
partials:
<?php echo Tag::partial(string|array $file); ?>
Base
Create a <base>
tag inside your <head>
tag:
<?php echo Tag::base(); ?>
Title
Create a <title>
tag inside your <head>
tag:
<?php echo Tag::title(string $text); ?>
Meta
Create a <meta>
tag inside your <head>
tag:
<?php echo Tag::meta(); ?>
Link
Create a <link>
tag inside your <head>
tag:
<?php echo Tag::link(); ?>
Style
Create a <style>
tag inside your <head>
tag:
<?php echo Tag::style(); ?>
Script
Create a <script>
tag inside your <head>
tag:
<?php echo Tag::script(); ?>
Breadcrumb
Display the breadcrumb:
<?php echo Tag::breadcrumb(array $optionArray); ?>
Default $optionArray
values:
[ 'className' => [ 'list' => 'rs-list-breadcrumb', 'divider' => 'rs-item-divider' ], 'divider' => null ]
Content
Display the contents from the router:
<?php echo Tag::content(); ?>
Article
Display the articles:
<?php echo Tag::article(int $categoryId, int $articleId, array $optionArray); ?>
Default $optionArray
values:
[ 'tag' => [ 'title' => 'h2', 'box' => 'div' ], 'className' => [ 'title' => 'rs-title-content', 'box' => 'rs-box-content' ], 'orderColumn' => 'rank', 'partial' => [ 'error' => 'error.phtml' ] ]
Comment
Display the comments:
<?php echo Tag::comment(int $articleId, array $optionArray); ?>
Default $optionArray
values:
[ 'tag' => [ 'title' => 'h3', 'box' => 'blockquote' ], 'className' => [ 'title' => 'rs-title-comment', 'box' => 'rs-quote-default' ], 'orderColumn' => 'rank' ]
Extra
Display the extras:
<?php echo Tag::extra(int $extraId, array $optionArray); ?>
Default $optionArray
values:
[ 'tag' => [ 'title' => 'h3', 'box' => 'div' ], 'className' => [ 'title' => 'rs-title-extra', 'box' => 'rs-box-extra' ], 'orderColumn' => 'rank' ]
Pagination
Display the pagination:
<?php echo Tag::pagination(string $type, int $parentId, array $optionArray); ?>
Default $optionArray
values:
[ 'className' => [ 'list' => 'rs-list-pagination', 'item' => [ 'first' => 'rs-item-first', 'previous' => 'rs-item-previous', 'next' => 'rs-item-next', 'last' => 'rs-item-last', 'number' => 'rs-item-number', 'active' => 'rs-item-active' ] ] ]
Navigation
Display the navigation:
<?php echo Tag::navigation(string $type, array $optionArray); ?>
Default $optionArray
values:
[ 'className' => [ 'list' => 'rs-list-{type}', 'active' => 'rs-item-active' ], 'orderColumn' => 'rank' ]
Comment form
Display the comment form:
<?php echo Tag::commentForm(int $articleId); ?>
Search form
Display the search form:
<?php echo Tag::searchForm(string $table); ?>Edit on GitHub
Template Helpers
Get registry
Get item from the registry:
<?php Helper::getRegistry(string $key); ?>
Get language
Get item from the language:
<?php Helper::getLanguage(string $key); ?>
Get setting
Get item from the settings:
<?php Helper::getSetting(string $key); ?>
Get title
Get the value for the title:
<?php Helper::getTitle(); ?>
Get canonical
Get the value for the canonical URL:
<?php Helper::getCanonical(); ?>
Get description
Get the value for the meta description:
<?php Helper::getDescription(); ?>
Get keywords
Get the value for the meta keywords:
<?php Helper::getKeywords(); ?>
Get robots
Get the value for the meta robots:
<?php Helper::getRobots(); ?>
Get transport
Get the PHP
to JavaScript
transport:
<?php Helper::getTransport(); ?>
Get direction
Get the language related direction:
<?php Helper::getDirection(); ?>
Get class
Get the CSS
class helpers:
<?php Helper::getClass(string $prefix); ?>
Get response code
Get the HTTP
response code:
<?php Helper::getResponseCode(); ?>
Get content
Get the content:
<?php Helper::getContent(string|array $file); ?>Edit on GitHub