example.php

main 67 lines · 1.8 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/**
3 * Title: Example page
4 *
5 * A page this theme adds to the site. It does not exist in ZnoteX - the theme
6 * invents it. Nothing to register anywhere: dropping this file in pages/ makes
7 * it live at page.php?p=example, wrapped in this theme's shell.
8 *
9 * Delete it, rename it, add ten more. The filename is the URL.
10 */
11?>
12<h1>An extra page</h1>
13
14<p>
15 This file is <code>layouts/_example/pages/example.php</code> and it is
16 reachable at <code>page.php?p=example</code>.
17</p>
18
19<p>
20 Write plain HTML. You have the whole engine available if you want it:
21 <code>$config</code>, <code>user_logged_in()</code>,
22 <code>db()->fetchAll($sql, $params)</code>, and every function in
23 <code>engine/function/</code>.
24</p>
25
26<h2>Example: pull something out of the database</h2>
27
28<?php
29$players = db()->fetchAll("
30 SELECT `name`, `level`, `vocation`
31 FROM `players`
32 ORDER BY `level` DESC
33 LIMIT 5;
34");
35?>
36
37<?php if (is_array($players) && $players): ?>
38 <table class="table table-striped">
39 <tr class="yellow">
40 <td>Name</td>
41 <td>Vocation</td>
42 <td>Level</td>
43 </tr>
44 <?php foreach ($players as $player): ?>
45 <tr>
46 <td>
47 <a href="characterprofile.php?name=<?= urlencode((string)$player['name']) ?>">
48 <?= htmlspecialchars((string)$player['name'], ENT_QUOTES, 'UTF-8') ?>
49 </a>
50 </td>
51 <td><?= htmlspecialchars(vocation_id_to_name((int)$player['vocation']), ENT_QUOTES, 'UTF-8') ?></td>
52 <td><?= (int)$player['level'] ?></td>
53 </tr>
54 <?php endforeach; ?>
55 </table>
56<?php else: ?>
57 <p>No characters yet.</p>
58<?php endif; ?>
59
60<h2>Want a different frame for this page?</h2>
61
62<p>
63 Add <code>shells/wide.php</code> to your theme and put
64 <code>&lt;?php theme_shell('wide'); ?&gt;</code> at the top of this file.
65 The page then renders inside that frame instead of the default one.
66</p>
67
Top