Cookbook

Cookbooks are recipes with a solution to howto questions or functionality of Zotonic.

For more generic guides, check the User Guide and the Developer Guide.

Browse recipes

Search the cookbook

45 items

Cookbook

Automatically add new users to a user group

Why When you create a person, you usually need to add it to a user group as well. You may want to automate this, in particular if you need to differentiate the user group based on the person’s category.

Cookbook

Create a custom controller

Zotonic comes with a large collection controllers that cover many use cases, so you’ll probably have to resort to custom controllers less often than you may be used to from other web frameworks. Still, the time may come…

Cookbook

Create a custom filter

Create custom template filters to change the way variables are rendered in your templates. By following some simple rules, Zotonic will automatically find the filter for you:

Cookbook

Create a custom model

In this chapter we will look at how to implement a model around the The Open Movie Database (OMDB) API.

Cookbook

Create a custom tag

Custom tags, internally called scomps , are module-defined tags, which are used when the logic is too complex to be executed in templates.

Cookbook

Custom pivots

Search can only sort and filter on resources that actually have a database column. Zotonic’s resources are stored in a serialized form. This allows you to very easily add any property to any resource but you cannot sort…

Cookbook

Custom search

Implement a custom search by observing the search_query notification in your module. Imagine you want to search cookies in your database that either have chocolate or do not:

Cookbook

Displaying a site map

For the benefit of search engines and fans of tables of contents you can easily provide a site map.

Cookbook

Dynamic select options using a wired template

Why Suppose you want to wire a change event for a select box to update a another select box, i.e. you want to wire the action to use the selected value when rendering the template.

Cookbook

Exometer metrics

Zotonic comes with a system for collecting and exporting metrics (such as how much memory is used, how many database requests were made, etc.) called Exometer. This cookbook details how to make use of that system to…

Cookbook

How to add a custom page block

Zotonic comes with a number of standard page blocks: Header, Text and Embed page. Additional page blocks are provided by modules, for example mod_survey uses page blocks extensively for composing surveys. Page blocks…

Cookbook

How to customise error pages

Specific error pages Zotonic’s controller_http_error first tries to find an error page template that is specific for the HTTP status code, named templates/error. status_code .tpl . So, to override the 404 template

Cookbook

Logging to Logstash

Logstash is often used for log centralization and analysis. This cookbook describes how to set up Zotonic for logging to Logstash over UDP. As mentioned in the Logging chapter, Zotonic uses Logger.

Cookbook

Overriding Zotonic

This chapter describes how to override the templates, styling and logic provided by Zotonic.

Cookbook

Pivot Templates

Search uses database indices on special pivot columns and full text fields.

Cookbook

Security, templates and XSS prevention

Ensuring that you don't fall victim to cross site scripting and other injection attacks takes vigilance, eye for details and especially some good naming habits.

Loading more results…