Creating Your First Page
This already
assumes that there is a simple table in your MySQL database that exists called users, and that it has
the following data:
Table Name: users
id first_name last_name
----------------------------
1 Rivers Cuomo
2 Eddie Vedder
3 Thom Yorke
First, we’ll need to add a new Z SQL Method within the same folder as our Z MySQL database connection called select_all_users, which will select all of the names from the table users. To make sure your query works correctly, you should choose “Add and Test” to test it.

Page Template (ZPT)
Next, we’ll need to add a new page template from the drop down menu located at the top right corner of the ZMI.

Under the id field of the page template enter listnames.
Insert the following code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">
<body>
<div metal:fill-slot="main">
<h1>My List of Names</h1>
<ul>
<li tal:repeat="records context/select_all_users">
<span tal:replace="records/first_name">First Name</span> <span tal:replace="records/last_name">Last Name</span>
</li>
</ul>
</div>
</body>
</html>
*Note – I’ve included a metal tag here so that this page will be displayed within the main content area of a Plone site.
By using the tal:repeat command, we loop through each record result of the select_all_users query and assign it to the variable records. Since our table contains 3 records, it will loop through 3 times. Each time it loops through, a call is being made for to retrieve the values of first_name and last_name and is displayed via the tal:replace command.
The rendered HTML will look like this:
...
...
<h1>My List of Names</h1>
<ul>
<li>Rivers Cuomo</li>
<li>Eddie Vedder</li>
<li>Thom Yorke</li>
</ul>
...
...
A few notes to consider:
Since this is a page template, it will not show up within Plone’s “Content” tab even though it exists in a folder in the ZMI. You will need to access it via a hard link. For example, if you created a folder called myfolder and placed listnames in that folder, you would be able to access it via /myfolder/listnames.
