Zotonic is an open source Web framework built with Erlang. It is fast, scalable and extensible, and has been built to support dynamic, interactive websites. Marc Worrell, the main architect of Zotonic, started working on the project in 2008.

Zotonic aims to be a CMS that is as easy to use as a PHP CMS but with all the advantages inherent in the Erlang environment.

Zotonic has obviously been influenced by PHP CMSs like WordPress, Drupal, etc. The difference is that it is written in Erlang. Its objective is to offer the performance and scalability advantages inherent in Erlang, effortlessly. More importantly, it hopes to be a framework in which you can create a new site using existing modules and not have to write any Erlang code. Obviously, at present, the range of modules available for Zotonic dwarfs the number of modules available for the common alternatives.

Let’s look at how to create two sites using virtual hosts on the same server and using the sample skeletons included in the Zotonic distribution.



Installation

Before starting, Erlang should be installed and the PostgreSQL database server should be running. Go to http://zotonic.com/download to get the current release. Unzip and run the Zotonic server as follows:

If you have cpanel or plesk webhosting then skip the these two steps. Just create database and usernames from cpanel/plesk webhost panels instead of doing following steps.

First, create the two databases:
Code:
$ su – postgres
$ createuser -P zotonic
$ createdb blogdb -O zotonic
$ createdb basesitedb -O zotonic
Now, create the two sites:
Code:
$ bin/zotonic addsite -u zotonic -P <db pw> -d basesitedb 
-s basesite basesite
$ bin/zotonic addsite -u zotonic -P <db pw>  -d blogdb  -s
blog blogsite
The options '-u' and '-P' specify the credentials to use for the database. The option '-d' specifies the database to be used and 's' specifies the skeleton to be used. Basesite and blogsite are the names of the sites, and are accessible using virtual host names—the same as the site names. Add the following entries to /etc/hosts:
Code:
127.0.0.1   blogsite
127.0.0.1   basesite
Now, browse blogsite:8000 and basesite:8000 and you will have two distinct sites.

Adding content
Each site has an admin module included in it. Explore the admin module by going to the url blogsite:8000/admin. You will see a page as shown below.

Name:  Zotonic admin module.jpg
Views: 336
Size:  66.3 KB


Choose the option to ‘make a new page’. You will need to give the page a title. Choose the category as 'article'. Select the ‘publish’ option. Now add some text and images in the form offered, and save it.

Now, if you go back to the home page, the newly added page should be the first item.

Repeat the same process with the basesite. In this case, the main content of the home page will not change. The newly added page and images will show up in the column on the right under ‘Recent content’.

Structure of a site
Look in the zotonic/priv/sites directory and you will find the directories basesite and blogsite, which contain all the site specific information. Each site needs a config file and a <site name>.erl file. The config file is an Erlang list that contains information about the site, the database and the modules to be installed. The erl file is essentially a minimal Erlang module.

Name:  The architecture of Zotonic.png
Views: 233
Size:  22.5 KB


Mapping of URLs to the Erlang modules is specified in the file dispatch/dispatch along with the parameters needed, if any. For example, you could specify the template to be used here. Zotonic, like Web Machine, also uses the erlydtl templates, an implementation of Django Template Language in Erlang.

In the sites directory, you will also find zotonic_status, which includes default templates and CSS files that are available for use on your site. For example, the file basesite/templates/home.tpl determines what is shown, and where, on the home page of the basesite. It includes and uses templates that are available in the zotonic_status site.

The templates can access system entities using pre-defined models, e.g., the main resource model or search model. These are used as m.rsc.x or m.search.x in the templates. You can refer to the in-depth manuals on http://zotonic.com/docs/ for more details.

As you may have deduced from this quick overview, Zotonic makes it possible to create a CMS site without having to write any Erlang code.

Zotonic Screenshots