The Zotonic shell gives you access to a running Zotonic instance with its code and data.
To connect to the background Zotonic server instance within an EShell (Erlang shell):
zotonic shell
Alternatively, use the debug commmand to launch the Zotonic server interactively and get an EShell on the running instance:
zotonic debug
The start.sh command in the root folder is a shortcut for this command.
The Zotonic shell has tab completion.
Add a colon to get all available functions from a module, for instance: m_rsc:<tab>.
The z module provides shortcuts for the most used commands. From within the Zotonic shell:
Sometimes it happens that you want to reset an user’s password from the Erlang shell. You can do this from the Erlang shell without using the admin or the reset-password mail/dialog.
Sometimes it is desirable to access data stored in Zotonic from the EShell. This is useful for experimenting with code without having to go through an involved process or through HTTP requests to test it.
These calls use the site context as parameter. Get it using:
Context = z:c(sitename).
The m_rsc model module provides functions for retrieving and interacting with pages and other resources stored in Zotonic’s datastore for the site.
Title = m_rsc:p(Id, title, Context).
You can also use the Erlang proplists module:
Title = proplists:get_value(title, RscProps).
To perform a search on the running site, use the z_search module.
To retrieve the list of pages, we access the result property of the record data:
Pages = Results#search_result.result.
Use m_rsc:get(Id, Context) to retrieve Page information of each search result (see above).
We have added the recon application to the zotonic deps. This allows one to easily debug many aspects of a running zotonic node. It contains tools for tracing calls, check memory and bandwidth usage and a lot more. For more information see: Stuff Goes Bad: Erlang in Anger.