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.
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
45 items
Rescuing a dysfunctional site from the Zotonic shell.
Common markup in admin templates.
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.
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…
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:
In this chapter we will look at how to implement a model around the The Open Movie Database (OMDB) API.
Custom tags, internally called scomps , are module-defined tags, which are used when the logic is too complex to be executed in templates.
Why For an imaginary webshop edit page, we want to add 2 more data fields: the affiliate URL and a note about free shipping.
Why After having created a custom widget (see Creating a custom widget on the edit page), we want to hide widgets that we don’t need.
You want to change parts of the form, or change its appearance.
How to make style customizations to admin pages.
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…
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:
Techniques for finding root cause when queries are involved.
For the benefit of search engines and fans of tables of contents you can easily provide a site map.
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.
Using growl outside admin requires some magic to make it work.
Get quicker access to Zotonic code on the shell.
The Zotonic task queue lets applications perform tasks asynchronously.
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…
Applying Erlang Binary syntax to get fast character manipulation.
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…
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
Zotonic provides a couple of ways to show icons in templates:
This tutorial teaches you to create a form, validate it, submit it over Ajax and e-mail the results back to you.
Zotonic source code have you scratching your head? Learn Rebar first.
Building a gen_server to front the library and generating documentation.
An indispensible tool for both learning and programming Erlang.
Understand the primary data-store of Zotonic.
Learn how to manipulate string data with the re module.
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.
Configure mod_signup to redirect to something other than a member’s home page.
This chapter describes how to override the templates, styling and logic provided by Zotonic.
Use edges ( page connections ) to associate backgrounds with pages.
Search uses database indices on special pivot columns and full text fields.
Emergency password reset when you can’t get into the admin interface.
Contributed by: Scott Finnie
Getting the category from a URL is somewhat involved, but not impossible. This is an example of what you can do with filters.
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.