M

modxTwig

By Aleksadr Poltarjonok (codenator)


For using plugin click on Elements tab and open Templates tree. Create new template for example name it index, check 'Is Static' and name indexController.php.

In Template code (html) put this code:

return $modx->twig->render('index.twig');

save your template and click on Resources tab. Click on the Home document and in "Uses Template"

change template on index.

Now you can see your front end just go to Site->View

For pass same variables in template write

$myvar = ['first'=>'Первый','sekond'=>'Второй','last'=>'Последний'];

$modx->twig->addGlobal('text', $myvar);return $modx->twig->render('index.twig');

to call $myvar in index.twig write{{ myvar.first }} and we get output 'Первый'

modx

================================================

$modx->getOption('site_url');{{ modx.Option('site_url') }}$modx->resource->content;{{ modx.resource.content }}

Snippe

t=================================================

min snippet`s call{{ snippet('mysnippet') }}

where Wayfinder snippet`s name and  {'startId':0} params{{ snippet('Wayfinder', {'startId':0}) }} Chunk===============================================

Chunk call{{ chunk('mychunk') }}Call chunk with params{{ chunk('mychunk',{'key':'value'}) }}

Placeholders

================================================

{{ ph('myplaceholder') }}

Configs

================================================

{{ config('site_start') }}with params{{ config('site_start':'default') }}

Link

================================================

{{ link('id') }}with params like {{ link('id',{'cultureKey':'ru'}) }}

Resources fields

=================================================

{{ field({'name':'fulltitle'}) }}

with params

{{ field({'name':'fulltitle','key':'value'} })field work with tv as wel

l=================================================

Add trans tag which work with lexicon entry

{{ trans('key','lang:namespace:topic',{'sport':'basketball'}) }}

where {'sport':'basketball'} placeholder in lexicon normaly call

{{ trans('key','namespace:topic') }}

My mail apoltarjonoks@gmail.com

Link to  my site with same tutorials to came http://codenator.dev-point.org/

Aleksadr Poltarjonok


New in modxTwig 1.0.0-rc2

Initial content

Added debug mode and caching

Rename to modxTwig for shorter name

Added cached snippet

More

Information

Released
June 18, 2014
Supported Versions
2.2 – 2.4
Downloads
1,139
License
GPLv2

Previous Versions

0.0.2-dev
June 13, 2014
2.2 – Current
More