ride/web-template-smarty

Smarty template integration for the base web application of the Ride framework

2.0.0 2024-04-19 13:14 UTC

README

This module adds template blocks, functions and modifiers for a Ride application to Smarty.

Block functions

[Smarty docs]

isGranted

Parse block content if the specified route/url/permission is allowed.

{isGranted permission="cms.node.varnish.manage"}
  ...
{/isGranted}

Note: The content of this block is always rendered. If the content is used for logic, assign the grant to a var and use an if statement.

isNotGranted

Parse block content if the specified route/url/permission is not allowed.

{isNotGranted permission="cms.node.varnish.manage"}
  ...
{/isNotGranted}

Note: The content of this block is always rendered. If the content is used for logic, assign the grant to a var and use an if statement.

Template functions

[Smarty docs]

apiMethodParameters

{apiMethodParameters method= url= namespace= classes=}

apiType

{apiType type= url= method= html= link= namespace= classes=}

image

Return the URL of a transformed image.

⚠️ Transformations may require additional parameters.

For more information about the transformations and their parameters, check out ride-lib-image.

{image src=$content->image var='image' transformation='crop'}

parsley

Adds parsley data attributes to the attributes of a form widget.

{$widget = $formRow->getWidget()}
{parsleyAttributes attributes=$widget->getAttributes() type=$widget->getType() var="attributes"}

tableVars

Add these FormTable variables to the template:

  • $tableNameField
  • $tableActionField
  • $tableIdField
  • $tableOrderField
  • $tableSearchQueryField
  • $tablePageRowsField
{tableVars}

translate

Translate a key using the i18n translator.

{translate key='label.submit' locale='nl'}

⚠️ When simply translating a key, using the {$key|translate} modifier syntax is preferred.

url

Create an URL.

{url id='api.search' var='searchUrl'}

Modifiers

[Smarty docs]

decorate

Common decorator IDs: storage.size / time / date.format / file / file.extension / file.size

{$content->data->getDatePublished()|decorate:'time'}

safe

Modify a string value to safely use it as a file name, URL, id etc.

{'Unsafe string!'|safe} {* result: unsafe-string *}

translate

{'label.fields.required'|translate}

Related Modules

Installation

You can use Composer to install this application.

composer require ride/web-template-smarty