Zotonic has obviously been influenced by PHP CMS's 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 (http://www.aosabook.org/en/posa/zotonic.html). 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 in comparison to the modules available for the common alternatives. In this article, you will see how to create two sites using virtual hosts on the same server using the sample skeletons included in Zotonic distribution. InstallationBefore starting, Erlang should be installed and 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:
Pointing a browser to localhost:8000 will show zotonic server running. Keep the server running and add two sites. First, create the two databases:
Now, create the two sites:
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. The basesite/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:
Now, browse blogsite:8000 and basesite:8000 and you will have two distict sites. Adding ContentEach 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 like in figure 1. Choose the option to make a new page. You will need to give a page title. Choose the category as article. Select the published 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 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 column on the right under 'Recent content'. Structure of a siteLook in the zotonic/priv/sites directory and you will find 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 which contains information about the site, the database and the modules to be installed. The erl file is essentially a minimal erlang module. Mapping of URL's to the Erlang modules is specified in the file dispatch/dispatch along with the parameters needed, if any. For example, you would specify the template to be used here. Zotonic, like webmachine, 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 which are available for use on your site. For example, the file basesite/templates/home.tpl determines what is shown where on the home page of the basesite. It includes and uses templates which 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 details. As you explored in this quick overview, zotonic makes it possible to create a CMS site without having to write any Erlang code. However, since the modules available may not meet all your needs, you may want to write a custom module, which we will explore next month. |
Exploring Software >