Then, in each dynamic routing actions you will need this line $this->storeNodeAndTranslation($node,$translation);
in order to make page content available from your Twig template.

node — [object]

nodeSource — [object]

translation — [object]

pageMeta

title — [string]

description — [string]

keywords — [string]

All these data will be available in your Twig template using {{ }} syntax.
For example use {{ pageMeta.title }} inside your head’s <title> tag.
You can of course call objects members within Twig using the dot separator.

Standard Twig path and url methods are both working for static and dynamic routing. In Roadiz, these methods
can take either a string identifier or a NodesSources instance. Of course optional parameters are available for
both, they will automatically create an http query string when using a node-source.

Most of yout front-end work will consist in editing Twig templating, Twig assignations and… Twig filters. Roadiz core entities are already linked together so you don’t have to prepare your data before rendering it. Basically, you can access nodes or node-sources data directly in Twig using the “dot” seperator.

There is even some magic about Twig when accessing private or protected fields:
just write the fieldname and it will use the getter method instead: {{nodeSource.content|markdown}} will be interpreted as {{nodeSource.getContent|markdown}} by Twig.

Note

Roadiz will transform your node-type fields names to camel-case to create getters and setters into you NS class.
So if you created a header_image field, getter will be named getHeaderImage().
However, if you called it headerimage, getter will be getHeaderimage()

You can access methods too! You will certainly need to get node-sources’ documents to display them. Instead of declaring each document
in your PHP controller before, you can directly use them in Twig:

{# # This statement will only grab *visible* children node-sources and # will order them ascendently according to their *title*. #}{%setchildrenBlocks=nodeSource|children({'node.visible':true},{'title':'ASC'})%}

Note

Calling getChildren() from a node-source handler or |children filter will always return NodesSources objects from the same translation as their parent.

In this example, we want to create links to jump to next and previous pages. We will use node-source handler methods
getPrevious() and getNext() which work the same as getChildren() method.
|previous and |next Twig filters are also available.

centralTruncate(length,offset,ellipsis): Generate an ellipsis at the middle of your text (useful for filenames). You can decenter the ellipsis position using offset parameter, and even change your ellipsis character with ellipsis parameter.

This filter returns some useful informations about current page available languages and their
urls. See getTranslationMenuAssignation method definition.
You do not have to pass it the current request object as the filter will grab it
for you. But you can specify if you want absolute urls or not.

Imagine now that your are rendering some dynamic CSS stylesheets with Twig.
Your are listing your website projects which all have a distinct color. So you’ve created a
CSS route and a dynamic-colors.css.twig.

Then you should see your “super project” title in red on your website. OK, that’s great.
But what should I do if I need to use a RGBA color to control the Alpha channel value?
For example, I want to set project color to a <divclass="date"> background like this:

You just have to extend setupDependencyInjection static method in your main
theme class. Create it if it does not exist yet.

// In your SuperThemeApp.phppublicstaticfunctionsetupDependencyInjection(\Pimple\Container$container){parent::setupDependencyInjection($container);// We extend twig filters$container->extend('twig.filters',function($filters,$c){// The first filter will extract red value$red=new\Twig_SimpleFilter('red',function($hex){if($hex[0]=='#'&&strlen($hex)==7){returnhexdec(substr($hex,1,2));}else{return0;}});$filters->add($red);// The second filter will extract green value$green=new\Twig_SimpleFilter('green',function($hex){if($hex[0]=='#'&&strlen($hex)==7){returnhexdec(substr($hex,3,2));}else{return0;}});$filters->add($green);// The third filter will extract blue value$blue=new\Twig_SimpleFilter('blue',function($hex){if($hex[0]=='#'&&strlen($hex)==7){returnhexdec(substr($hex,5,2));}else{return0;}});$filters->add($blue);// Then we return our extended filters collectionreturn$filters;});}

And… Voilà! You can use red, green and blue filters in your Twig template.