Cook book category

 

46 cook book

Activate/deactivate modules cook book

Rescuing a dysfunctional site from the Zotonic shell. Why Sometimes it happens that disabled or enabled a module by accident and your whole site is now dysfunctional. You can easily rescue your site

Add Chat to Your Zotonic Site cook book

Thanks to Michael Connor’s zchat , it’s easy to add chat system on your Zotonic site. Why It is often very useful for a site to have a live support line built-in. Another case for chat is on a…

Admin template specific things cook book

Common markup in admin templates. Linking to edit pages Dispatches to edit pages is done by admin_edit_rsc . Linking: { % url admin_edit_rsc id=my_id %} Redirecting: { % button text="edit"…

Automatically add new users to a user group cook book

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…

Cookbooks cook book

Create a custom action Create a custom filter Create a custom model Create a custom controller Custom pivots Create a custom tag Custom search Pivot Templates Writing your own module Overriding…

Create a custom controller cook book

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.

Create a custom filter cook book

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: Create a file in the…

Create a custom model cook book

In this chapter we will look at how to implement a model around the The Open Movie Database (OMDB) API . We will touch useful background information at the same time. Model modules Models are Erlang…

Create a custom tag cook book

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

Creating a custom widget on the edit page cook book

Why For an imaginary webshop edit page, we want to add 2 more data fields: the affiliate URL and a note about free shipping. Assumptions Readers are expected to have experience with Zotonic…

Customizing the layout of the admin edit page cook book

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. Assumptions Readers are expected to have experience with…

Customizing the sign up and sign in form cook book

You want to change parts of the form, or change its appearance. Sign up form The sign up form is called with dispatch rule signup , implemented by mod_signup . This module must be enabled to view…

Customizing the style of an admin page cook book

How to make style customizations to admin pages. Assumptions Readers are expected to have experience with Zotonic templates. How Creating a custom style for admin pages is best done using a…

Custom pivots cook book

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…

Custom search cook book

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: - include_lib…

Debugging db (query) issues cook book

Techniques for finding root cause when queries are involved. Why When you face unexpected behavior as a result of some database query (z_db:q et al), you either have to hunt down the queries and re

Displaying a site map cook book

For the benefit of search engines and fans of tables of contents you can easily provide a site map. Note This article discusses HTML site maps. For the XML kind which Google uses, see…

Dynamic select options using a wired template cook book

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. Assumptions…

Enabling Growl Notifications cook book

Using growl outside admin requires some magic to make it work. Why Growls provide an unobtrusive way of notifying users of background events or the completion of tasks. This guide provides step-by

Erlang tab completion cook book

Get quicker access to Zotonic code on the shell. Contributed by: Maas-Maarten Zeeman Why When you are working on the shell chances are you are looking to be fast. A way to be faster is to leverage…

Execute tasks asynchronously using the task queue cook book

The Zotonic task queue lets applications perform tasks asynchronously. Let’s say you have some external HTTP API that you want to update whenever a resource in Zotonic is changed. You can so by…

Exometer metrics cook book

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…

Filter and convert characters cook book

Applying Erlang Binary syntax to get fast character manipulation. Author: Lloyd R. Prentice Co-Author: Andreas Stenius Why Erlang bit syntax is extraordinarily powerful and well worth learning.

How to add a custom Content Block cook book

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

How to customise error pages cook book

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…

Icons in templates cook book

Zotonic provides a couple of ways to show icons in templates: mod_artwork gives access to FontAwesome and Material Design icons. It also has a number of other icon collections, mostly PNG images.

Implementing a simple contact form cook book

This tutorial teaches you to create a form, validate it, submit it over Ajax and e-mail the results back to you. Why Making a simple contact form might seem difficult, but with the smart application…

Just enough Erlang/OTP and rebar, part 1 cook book

Zotonic source code have you scratching your head? Learn Rebar first. Created Aug 8, 2011 by Lloyd R. Prentice Why Rebar is a relatively new set of Erlang/OTP development tools. Rebar makes it…

Just enough Erlang/OTP and rebar, part 2 cook book

Building a gen_server to front the library and generating documentation. Created Aug 17, 2011 by Lloyd R. Prentice WHY If you worked through the Cookbook item Just enough Erlang/OTP and rebar, part…

Just enough Erlang shell cook book

An indispensible tool for both learning and programming Erlang. Submitted by: LRP; July 30, 2011 WHY You don’t need to know Erlang or use the Erlang shell to create simple Zotonic websites. But for…

Just enough Postgres cook book

Understand the primary data-store of Zotonic. Why Data persistence in Zotonic is provided by PostgreSQL, a mature feature-rich open-source relational database. Since Zotonic provides both a data…

Just Enough Regular Expressions (in Erlang) cook book

Learn how to manipulate string data with the re module. Lloyd R. Prentice August 31, 2011 WHY The Erlang standard library re provides a powerful suite of functions to excute regular expressions to…

Logging to Logstash cook book

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 the…

Managing redirection after login and signup cook book

Configure mod_signup to redirect to something other than a member’s home page. Why The default behavior of Zotonic is to redirect the user to his or her own page after logon (/page). If you want to…

Overriding Zotonic cook book

This chapter describes how to override the templates, styling and logic provided by Zotonic. Overriding works by adding a site or module that has a higher priority than Zotonic’s built-in modules. In…

Page-specific dynamic backgrounds cook book

Use edges ( page connections ) to associate backgrounds with pages. Contributed by: Dmitrii Dimandt Why This is a small use case with a lot of words pouring into it. I’m doing a very small project…

Pivot Templates cook book

Search uses database indices on special pivot columns and full text fields. These columns and text fields are extracted in a process called pivoting . This is done a short period after a resource has…

Reset a user’s password cook book

Emergency password reset when you can’t get into the admin interface. Why Sometimes it happens that you want to reset an user’s password from the Erlang shell. Assumptions Readers are expected to…

Restore/upgrade content db from backup cook book

Contributed by: Scott Finnie How to protect your Zotonic content and bring it back in case of disaster. Why Restore / upgrade the content for a site from a database dump. Assumptions You have a…

Retrieving the category of a page cook book

Getting the category from a URL is somewhat involved, but not impossible. This is an example of what you can do with filters. Why It is often useful to use a page’s category to present it on the…

Share variable binding across blocks cook book

How to avoid having to call the same query inside several blocks of the same page Why In some situations, you may have to use the same query result inside several blocks of the same template. For…

Site-specific signup actions cook book

Performing additional, project-specific actions when a user signs up Why When a user signs up, Zotonic verifies the validity of some information, such as the e-mail address and the password strength.

Storing date/time fields cook book

Some interesting tidbits about saving/updating a date/time field of a resource. Why The purpose of this guide is to explain how Zotonic stores date-time data so that you can work with it in your own…

Updating form field from a dialog cook book

Ever wanted to update a form field from a dialog, possibly giving the user some list to choose from? Here’s how to do it. Why Some interactions benefit from presenting a dialog for input. This…

Writing your own module cook book

Todo Write this cookbook chapter