Download the PHP package vierwd/typo3-smarty without Composer
On this page you can find all versions of the php package vierwd/typo3-smarty. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package typo3-smarty
TYPO3 Smarty Extension
Use Smarty in your templates and extbase extensions.
Installation
Install using composer:
Usage in controllers
To use smarty templates for your extension's actions, just extend the Vierwd\VierwdSmarty\Controller\ActionController
. Your templates need to be at the same location as your Fluid templates used to be, but with the file extension .tpl
.
Example
Pre-defined variables
There are some variables, that are always available to your templates:
Variable Name | Contents |
---|---|
cObj | The current ContentObject (instance of TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer ) |
extensionPath | The path to your extension (typo3conf/ext/example_blog/ ) |
extensionName | ExampleBlog |
pluginName | Pi1 (or whatever you defined in ext_tables.php) |
controllerName | Blog |
actionName | list |
context | The controllerContext (instance of TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext ) |
request | The current request (instance of TYPO3\CMS\Extbase\MvcRequest ) |
formPrefix | Prefix form fields need as name to automatically map form fields to arguments |
settings | Flexform settings for the plugin |
frameworkSettings | TypoScript settings for plugin.tx_exampleblog |
typolinkService | An instance of TYPO3\CMS\Frontend\Service\TypoLinkCodecService |
TSFE | $TSFE (instance of TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController ) |
Pre-defined smarty functions, blocks and modifiers
- translate
- uri_resource
- uri_action
- link_action
- flashMessages
- nl2p
- typolink
- typoscript
- fluid
- svg
Power-Blocks: typoscript and fluid
What's realy good about this extension is, that you can still use typoscript and fluid within your Smarty templates. That way you can ensure, that an element gets exactly the same HTML output as a normal content element like Text-with-images. If you write a form, it's also good to fallback to Fluid for some ViewHelpers.
Typoscript
Output (Line-breaks added)
The changes to the typoscript will not persist. That way you can remove lib.parseFunc_RTE
in one TypoScript Block and still use it in another. It is also possible to use an array data
for all arguments:
Notice, that parameters in the block-tag override array keys (in this example header_layout):
Output (Line-breaks added)
Using Smarty for the base template
It is also possible to use Smarty for the base template of your website in your main TypoScript setup
All entries in settings.typoscript will be parsed and will be available as variables in your template.
Note the nofilter argument for Smarty. By default all variables will be escaped to prevent some XSS attacks.
Using Smarty for Menus
This code block will load the templates at typo3conf/ext/vierwd_example/Resources/Private/Templates/Navigation/
to render the navigation. Within the template you can iterate over your menu items and output the menu: