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):
Alternatively, use the debug commmand to launch the Zotonic server interactively and get an EShell on the running instance:
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).