Edit on GitHub
Jump to docs navigation

Extending / Storage Layer / Working with Directives

Note: You are currently reading the documentation for Bolt 3.1. Looking for the documentation for Bolt 3.5 instead?

OverviewΒΆ

Directives are short segments of code that include an __invoke statement and manipulate queries. A good example of this would be the LimitHandler. As you can see the code is very simplistic and all it does is manipulates the query builder and sets a limit on the result.

The code that would execute the LimitHandler would be: {% setcontent mypages = 'pages' limit 1 %}

You can add your own directive by creating a new extension, and registering it as a directive handler for the content parser service. An example of doing that would be: $app['query.parser']->addDirectiveHandler('limit', new LimitHandler());

Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.