Mercurial > hg > vamp-website
comparison forum/ssi_examples.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Simple Machines Forum (SMF) | |
5 * | |
6 * @package SMF | |
7 * @author Simple Machines http://www.simplemachines.org | |
8 * @copyright 2011 Simple Machines | |
9 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
10 * | |
11 * @version 2.0 | |
12 */ | |
13 | |
14 // Special thanks to Spaceman-Spiff for his contributions to this page. | |
15 | |
16 /* Define $ssi_guest_access variable just before including SSI.php to handle guest access to your script. | |
17 false: (default) fallback to forum setting | |
18 true: allow guest access to the script regardless | |
19 */ | |
20 $ssi_guest_access = false; | |
21 | |
22 // Include the SSI file. | |
23 require(dirname(__FILE__) . '/SSI.php'); | |
24 | |
25 // Viewing the homepage sample? | |
26 if (isset($_GET['view']) && $_GET['view'] == 'home1') | |
27 { | |
28 template_homepage_sample1('output'); | |
29 exit; | |
30 } | |
31 | |
32 // Load the main template. | |
33 template_ssi_above(); | |
34 ?> | |
35 | |
36 <h2>SMF SSI.php Functions</h2> | |
37 <p><strong>Current Version:</strong> 2.0</p> | |
38 <p>This file is used to demonstrate the capabilities of SSI.php using PHP include functions. The examples show the include tag, then the results of it.</p> | |
39 | |
40 <h2>Include Code</h2> | |
41 <p>To use SSI.php in your page add at the very top of your page before the <html> tag on line 1 of your php file:</p> | |
42 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php require("<?php echo addslashes($user_info['is_admin'] ? realpath($boarddir . '/SSI.php') : 'SSI.php'); ?>"); ?></code> | |
43 | |
44 <h2>Some notes on usage</h2> | |
45 <p>All the functions have an output method parameter. This can either be "echo" (the default) or "array"</p> | |
46 <p>If it is "echo", the function will act normally - otherwise, it will return an array containing information about the requested task. For example, it might return a list of topics for ssi_recentTopics.</p> | |
47 <p onclick="if (getInnerHTML(this).indexOf('Bird') == -1) setInnerHTML(this, getInnerHTML(this) + '<br /><img src="http://www.simplemachines.org/images/chocobo.jpg" title="Bird-san" alt="Chocobo!" />'); return false;">This functionality can be used to allow you to present the information in any way you wish.</p> | |
48 | |
49 <h2>Additional Guides & FAQ</h2> | |
50 <p>Need more information on using SSI.php? Check out <a href="http://docs.simplemachines.org/index.php?topic=400.0">Using SSI.php article</a> or <a href="http://www.simplemachines.org/community/index.php?topic=14906.0">the SSI FAQ</a>.</p> | |
51 | |
52 <div id="sidenav" class="windowbg"> | |
53 <span class="topslice"><span></span></span> | |
54 <div class="content"> | |
55 <h2 id="functionlist">Function List</h2> | |
56 <h3>Recent Items</h3> | |
57 <ul> | |
58 <li><a href="#" onclick="showSSIBlock('ssi_recentTopics'); return false;">Recent Topics</a></li> | |
59 <li><a href="#" onclick="showSSIBlock('ssi_recentPosts'); return false;">Recent Posts</a></li> | |
60 <li><a href="#" onclick="showSSIBlock('ssi_recentPoll'); return false;">Recent Poll</a></li> | |
61 </ul> | |
62 <h3>Top Items</h3> | |
63 <ul> | |
64 <li><a href="#" onclick="showSSIBlock('ssi_topBoards'); return false;">Top Boards</a></li> | |
65 <li><a href="#" onclick="showSSIBlock('ssi_topTopicsViews'); return false;">Top Topics</a></li> | |
66 <li><a href="#" onclick="showSSIBlock('ssi_topPoll'); return false;">Top Poll</a></li> | |
67 <li><a href="#" onclick="showSSIBlock('ssi_topPoster'); return false;">Top Poster</a></li> | |
68 </ul> | |
69 <h3>Members</h3> | |
70 <ul> | |
71 <li><a href="#" onclick="showSSIBlock('ssi_latestMember'); return false;">Latest Member Function</a></li> | |
72 <li><a href="#" onclick="showSSIBlock('ssi_randomMember'); return false;">Member of the Day</a></li> | |
73 <li><a href="#" onclick="showSSIBlock('ssi_whosOnline'); return false;">Who's Online</a></li> | |
74 </ul> | |
75 <h3>Authentication</h3> | |
76 <ul> | |
77 <li><a href="#" onclick="showSSIBlock('ssi_login'); return false;">Welcome, Login & Logout</a></li> | |
78 </ul> | |
79 <h3>Calendar</h3> | |
80 <ul> | |
81 <li><a href="#" onclick="showSSIBlock('ssi_todaysCalendar'); return false;">Today's Events</a></li> | |
82 <li><a href="#" onclick="showSSIBlock('ssi_recentEvents'); return false;">Recent Events</a></li> | |
83 </ul> | |
84 <h3>Miscellaneous</h3> | |
85 <ul> | |
86 <li><a href="#" onclick="showSSIBlock('ssi_boardStats'); return false;">Forum Stats</a></li> | |
87 <li><a href="#" onclick="showSSIBlock('ssi_news'); return false;">News</a></li> | |
88 <li><a href="#" onclick="showSSIBlock('ssi_boardNews'); return false;">Board News</a></li> | |
89 <li><a href="#" onclick="showSSIBlock('ssi_menubar'); return false;">Menubar</a></li> | |
90 <li><a href="#" onclick="showSSIBlock('ssi_quickSearch'); return false;">Quick Search Box</a></li> | |
91 <li><a href="#" onclick="showSSIBlock('ssi_recentAttachments'); return false;">Recent Attachments</a></li> | |
92 </ul> | |
93 <?php if ($user_info['is_admin']) { ?> | |
94 <h3>Advanced Functions <img class="help" title="Functions that require additional tweaking, not just copy and paste." src="<?php echo $settings['images_url']; ?>/helptopics.gif" alt="" /></h3> | |
95 <ul> | |
96 <li><a href="#" onclick="showSSIBlock('ssi_showPoll'); return false;">Show Single Poll</a></li> | |
97 <li><a href="#" onclick="showSSIBlock('ssi_fetchPosts'); return false;">Show Single Post</a></li> | |
98 <li><a href="#" onclick="showSSIBlock('ssi_fetchMember'); return false;">Show Single Member</a></li> | |
99 <li><a href="#" onclick="showSSIBlock('ssi_fetchGroupMembers'); return false;">Show Group Members</a></li> | |
100 </ul> | |
101 <?php } ?> | |
102 <h3>Website Samples</h3> | |
103 <ul> | |
104 <li><a href="#" onclick="showSSIBlock('htmlhome')">Sample 1</a></li> | |
105 </ul> | |
106 <h2 id="other">Other</h2> | |
107 <ul> | |
108 <li><a href="#" onclick="toggleVisibleByClass('ssi_preview', false); return false;">Show all examples</a></li> | |
109 <li><a href="#" onclick="toggleVisibleByClass('ssi_preview', true); return false;">Hide all examples</a></li> | |
110 </ul> | |
111 </div> | |
112 <span class="botslice"><span></span></span> | |
113 </div> | |
114 | |
115 <div id="preview" class="windowbg2"> | |
116 <span class="topslice"><span></span></span> | |
117 <div class="content"> | |
118 | |
119 <!-- RECENT ITEMS --> | |
120 <div class="ssi_preview" id="ssi_recentTopics"> | |
121 <h2>Recent Topics Function</h2> | |
122 <h3>Code (simple mode)</h3> | |
123 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentTopics(); ?></code> | |
124 <h3>Code (advanced mode)</h3> | |
125 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?></code> | |
126 <h3>Result</h3> | |
127 <div class="ssi_result"><?php ssi_recentTopics(); flush(); ?></div> | |
128 </div> | |
129 | |
130 <div class="ssi_preview" id="ssi_recentPosts"> | |
131 <h2>Recent Posts Function</h2> | |
132 <h3>Code</h3> | |
133 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentPosts(); ?></code> | |
134 <h3>Result</h3> | |
135 <div class="ssi_result"><?php ssi_recentPosts(); flush(); ?></div> | |
136 </div> | |
137 | |
138 <div class="ssi_preview" id="ssi_recentPoll"> | |
139 <h2>Recent Poll Function</h2> | |
140 <h3>Code</h3> | |
141 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentPoll(); ?></code> | |
142 <h3>Result</h3> | |
143 <div class="ssi_result"><?php ssi_recentPoll(); flush(); ?></div> | |
144 </div> | |
145 | |
146 <!-- TOP ITEMS --> | |
147 <div class="ssi_preview" id="ssi_topBoards"> | |
148 <h2>Top Boards Function</h2> | |
149 <p>Shows top boards by the number of posts.</p> | |
150 | |
151 <h3>Code</h3> | |
152 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_topBoards(); ?></code> | |
153 <h3>Result</h3> | |
154 <div class="ssi_result"><?php ssi_topBoards(); flush(); ?></div> | |
155 </div> | |
156 | |
157 <div class="ssi_preview" id="ssi_topTopicsViews"> | |
158 <h2>Top Topics</h2> | |
159 <p>Shows top topics by the number of replies or views.</p> | |
160 | |
161 <h3>Code (show by number of views)</h3> | |
162 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_topTopicsViews(); ?></code> | |
163 <h3>Result</h3> | |
164 <div class="ssi_result"><?php ssi_topTopicsViews(); flush(); ?></div> | |
165 | |
166 <h3>Code (show by number of replies)</h3> | |
167 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_topTopicsReplies(); ?></code> | |
168 <h3>Result</h3> | |
169 <div class="ssi_result"><?php ssi_topTopicsReplies(); flush(); ?></div> | |
170 </div> | |
171 | |
172 <div class="ssi_preview" id="ssi_topPoll"> | |
173 <h2>Top Poll Function</h2> | |
174 <p>Shows the most-voted-in poll.</p> | |
175 | |
176 <h3>Code</h3> | |
177 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_topPoll(); ?></code> | |
178 <h3>Result</h3> | |
179 <div class="ssi_result"><?php ssi_topPoll(); flush(); ?></div> | |
180 </div> | |
181 | |
182 <div class="ssi_preview" id="ssi_topPoster"> | |
183 <h2>Top Poster Function</h2> | |
184 Shows the top poster's name and profile link. | |
185 | |
186 <h3>Code</h3> | |
187 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_topPoster(); ?></code> | |
188 <h3>Result</h3> | |
189 <div class="ssi_result"><?php ssi_topPoster(); flush(); ?></div> | |
190 </div> | |
191 | |
192 <!-- MEMBERS --> | |
193 <div class="ssi_preview" id="ssi_latestMember"> | |
194 <h2>Latest Member Function</h2> | |
195 <p>Shows the latest member's name and profile link.</p> | |
196 | |
197 <h3>Code</h3> | |
198 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_latestMember(); ?></code> | |
199 <h3>Result</h3> | |
200 <div class="ssi_result"><?php ssi_latestMember(); flush(); ?></div> | |
201 </div> | |
202 | |
203 <div class="ssi_preview" id="ssi_randomMember"> | |
204 <h2>Member of the Day</h2> | |
205 <p>Shows one random member of the day. This changes once a day.</p> | |
206 | |
207 <h3>Code</h3> | |
208 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_randomMember('day'); ?></code> | |
209 <h3>Result</h3> | |
210 <div class="ssi_result"><?php ssi_randomMember('day'); flush(); ?></div> | |
211 </div> | |
212 | |
213 <div class="ssi_preview" id="ssi_whosOnline"> | |
214 <h2>Who's Online Function</h2> | |
215 <p>This function shows who are online inside the forum.</p> | |
216 | |
217 <h3>Code</h3> | |
218 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_whosOnline(); ?></code> | |
219 <h3>Result</h3> | |
220 <div class="ssi_result"><?php ssi_whosOnline(); flush(); ?></div> | |
221 | |
222 <h2>Log Online Presence</h2> | |
223 <p>This function logs the SSI page's visitor, then shows the Who's Online list. In other words, this function shows who are online inside and outside the forum.</p> | |
224 | |
225 <h3>Code</h3> | |
226 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_logOnline(); ?></code> | |
227 <h3>Result</h3> | |
228 <div class="ssi_result"><?php ssi_logOnline(); flush(); ?></div> | |
229 </div> | |
230 | |
231 <!-- WELCOME, LOGIN AND LOGOUT --> | |
232 <div class="ssi_preview" id="ssi_login"> | |
233 <h2>Login Function</h2> | |
234 <p>Shows a login box only when user is not logged in.</p> | |
235 | |
236 <h3>Code</h3> | |
237 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_login(); ?></code> | |
238 <h3>Result</h3> | |
239 <div class="ssi_result"><?php ssi_login(); flush(); ?></div> | |
240 | |
241 <h2>Logout Function</h2> | |
242 <p>Shows a logout link only when user is logged in.</p> | |
243 | |
244 <h3>Code</h3> | |
245 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_logout(); ?></code> | |
246 <h3>Result</h3> | |
247 <div class="ssi_result"><?php ssi_logout(); flush(); ?></div> | |
248 | |
249 <h2>Welcome Function</h2> | |
250 <p>Greets users or guests, also shows user's messages if logged in.</p> | |
251 | |
252 <h3>Code</h3> | |
253 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_welcome(); ?></code> | |
254 <h3>Result</h3> | |
255 <div class="ssi_result"><?php ssi_welcome(); flush(); ?></div> | |
256 </div> | |
257 | |
258 <!-- CALENDAR --> | |
259 <div class="ssi_preview" id="ssi_todaysCalendar"> | |
260 <h2>Today's Calendar Function</h2> | |
261 <h3>Code</h3> | |
262 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_todaysCalendar(); ?></code> | |
263 <h3>Result</h3> | |
264 <div class="ssi_result"><?php ssi_todaysCalendar(); flush(); ?></div> | |
265 | |
266 <h2>Today's Birthdays Function</h2> | |
267 <h3>Code</h3> | |
268 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_todaysBirthdays(); ?></code> | |
269 <h3>Result</h3> | |
270 <div class="ssi_result"><?php ssi_todaysBirthdays(); flush(); ?></div> | |
271 | |
272 <h2>Today's Holidays Function</h2> | |
273 <h3>Code</h3> | |
274 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_todaysHolidays(); ?></code> | |
275 <h3>Result</h3> | |
276 <div class="ssi_result"><?php ssi_todaysHolidays(); flush(); ?></div> | |
277 | |
278 <h2>Today's Events Function</h2> | |
279 <h3>Code</h3> | |
280 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_todaysEvents(); ?></code> | |
281 <h3>Result</h3> | |
282 <div class="ssi_result"><?php ssi_todaysEvents(); flush(); ?></div> | |
283 </div> | |
284 | |
285 <div class="ssi_preview" id="ssi_recentEvents"> | |
286 <h2>Recent Calendar Events Function</h2> | |
287 | |
288 <h3>Code</h3> | |
289 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentEvents(); ?></code> | |
290 <h3>Result</h3> | |
291 <div class="ssi_result"><?php ssi_recentEvents(); flush(); ?></div> | |
292 </div> | |
293 | |
294 <!-- MISCELLANEOUS --> | |
295 <div class="ssi_preview" id="ssi_boardStats"> | |
296 <h2>Forum Stats</h2> | |
297 <p>Shows some basic forum stats: total members, posts, topics, boards, etc.</p> | |
298 | |
299 <h3>Code</h3> | |
300 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_boardStats(); ?></code> | |
301 <h3>Result</h3> | |
302 <div class="ssi_result"><?php ssi_boardStats(); flush(); ?></div> | |
303 </div> | |
304 | |
305 <div class="ssi_preview" id="ssi_news"> | |
306 <h2>News Function</h2> | |
307 <p>Shows random forum news.</p> | |
308 | |
309 <h3>Code</h3> | |
310 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_news(); ?></code> | |
311 <h3>Result</h3> | |
312 <div class="ssi_result"><?php ssi_news(); flush(); ?></div> | |
313 </div> | |
314 | |
315 <div class="ssi_preview" id="ssi_boardNews"> | |
316 <h2>Board News Function</h2> | |
317 <p>Shows the latest posts from read only boards, or a specific board.</p> | |
318 | |
319 <h3>Code</h3> | |
320 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_boardNews(); ?></code> | |
321 <h3>Result</h3> | |
322 <div class="ssi_result"><?php ssi_boardNews(); flush(); ?></div> | |
323 </div> | |
324 | |
325 <div class="ssi_preview" id="ssi_menubar"> | |
326 <h2>Menubar Function</h2> | |
327 <p>Displays a menu bar, like one displayed at the top of the forum.</p> | |
328 | |
329 <h3>Code</h3> | |
330 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_menubar(); ?></code> | |
331 <h3>Result</h3> | |
332 <div class="ssi_result"><?php ssi_menubar(); flush(); ?></div> | |
333 </div> | |
334 | |
335 <div class="ssi_preview" id="ssi_quickSearch"> | |
336 <h2>Quick Search Function</h2> | |
337 | |
338 <h3>Code</h3> | |
339 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_quickSearch(); ?></code> | |
340 <h3>Result</h3> | |
341 <div class="ssi_result"><?php ssi_quickSearch(); flush(); ?></div> | |
342 </div> | |
343 | |
344 <div class="ssi_preview" id="ssi_recentAttachments"> | |
345 <h2>Recent Attachments Function</h2> | |
346 | |
347 <h3>Code</h3> | |
348 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_recentAttachments(); ?></code> | |
349 <h3>Result</h3> | |
350 <div class="ssi_result"><?php ssi_recentAttachments(); flush(); ?></div> | |
351 </div> | |
352 | |
353 <!-- ADVANCED FUNCTIONS --> | |
354 <div class="ssi_preview" id="ssi_showPoll"> | |
355 <h2>Show Single Poll</h2> | |
356 <p>Shows a poll in the specified topic.</p> | |
357 | |
358 <h3>Code</h3> | |
359 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_showPoll($topicID); ?></code> | |
360 <h3>Result</h3> | |
361 <div class="ssi_result"><i>Not shown because it needs specific topic ID that contains a poll.</i></div> | |
362 </div> | |
363 | |
364 <div class="ssi_preview" id="ssi_fetchPosts"> | |
365 <h2>Show Single Post</h2> | |
366 <p>Fetches a post with a particular IDs. By default will only show if you have permission to the see | |
367 the board in question. This can be overriden by passing the 2nd parameter as <tt>true</tt>.</p> | |
368 | |
369 <h3>Code</h3> | |
370 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_fetchPosts($postIDs, $isOverride); ?></code> | |
371 <h3>Result</h3> | |
372 <div class="ssi_result"><i>Not shown because it needs a specific post ID.</i></div> | |
373 </div> | |
374 | |
375 <div class="ssi_preview" id="ssi_fetchMember"> | |
376 <h2>Show Single Member</h2> | |
377 <p>Shows the specified member's name and profile link.</p> | |
378 | |
379 <h3>Code</h3> | |
380 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_fetchMember($memberIDs); ?></code> | |
381 <h3>Result</h3> | |
382 <div class="ssi_result"><i>Not shown because it needs a specific member ID.</i></div> | |
383 </div> | |
384 | |
385 <div class="ssi_preview" id="ssi_fetchGroupMembers"> | |
386 <h2>Show Group Members</h2> | |
387 <p>Shows all members in a specified group.</p> | |
388 | |
389 <h3>Code</h3> | |
390 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_fetchGroupMembers($groupIDs); ?></code> | |
391 <h3>Result</h3> | |
392 <div class="ssi_result"><i>Not shown because it needs specific membergroup IDs.</i></div> | |
393 </div> | |
394 | |
395 <div class="ssi_preview" id="htmlhome"> | |
396 <h2>Home Page Sample</h2> | |
397 This sample uses the following features: ssi_recentTopics(), ssi_logOnline(), ssi_welcome(), and ssi_boardNews(). | |
398 ssi_recentTopics() is fetched using the array method, to allow further customizations on the output. | |
399 | |
400 <h3>Code</h3> | |
401 <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php echo htmlspecialchars(template_homepage_sample1('source')); ?></code> | |
402 <h3>Result</h3> | |
403 <iframe src="?view=home1" width="99%" height="300"></iframe> | |
404 </div> | |
405 </div> | |
406 <span class="botslice"><span></span></span> | |
407 </div> | |
408 | |
409 <?php | |
410 | |
411 template_ssi_below(); | |
412 | |
413 function template_ssi_above() | |
414 { | |
415 global $settings, $context, $scripturl; | |
416 | |
417 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
418 <html xmlns="http://www.w3.org/1999/xhtml"> | |
419 <head> | |
420 <title>SMF 2.0 SSI.php Examples</title> | |
421 <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css?fin20" /> | |
422 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script> | |
423 <style type="text/css"> | |
424 #wrapper | |
425 { | |
426 width: 90%; | |
427 } | |
428 #upper_section .user | |
429 { | |
430 height: 4em; | |
431 } | |
432 #upper_section .news | |
433 { | |
434 height: 80px; | |
435 } | |
436 #content_section | |
437 { | |
438 position: relative; | |
439 top: -20px; | |
440 } | |
441 #main_content_section h2 | |
442 { | |
443 font-size: 1.5em; | |
444 border-bottom: solid 1px #d05800; | |
445 line-height: 1.5em; | |
446 margin: 0.5em 0; | |
447 color: #d05800; | |
448 } | |
449 #liftup | |
450 { | |
451 position: relative; | |
452 top: -70px; | |
453 padding: 1em 2em 1em 1em; | |
454 line-height: 1.6em; | |
455 } | |
456 #footer_section | |
457 { | |
458 position: relative; | |
459 top: -20px; | |
460 } | |
461 #sidenav | |
462 { | |
463 width: 210px; | |
464 float: left; | |
465 margin-right: 20px; | |
466 } | |
467 #sidenav ul | |
468 { | |
469 margin: 0 0 0 15px; | |
470 padding: 0; | |
471 list-style: none; | |
472 font-size: 90%; | |
473 } | |
474 #preview | |
475 { | |
476 margin-left: 230px; | |
477 } | |
478 .ssi_preview | |
479 { | |
480 margin-bottom: 1.5em; | |
481 } | |
482 .ssi_preview h3 | |
483 { | |
484 margin: 1em 0 0.5em 0; | |
485 } | |
486 .ssi_result | |
487 { | |
488 background-color: #fff; | |
489 border: 1px solid #99a; | |
490 padding: 10px; | |
491 overflow: hidden; | |
492 } | |
493 </style> | |
494 <script type="text/javascript"><!-- // --><![CDATA[ | |
495 var smf_scripturl = "', $scripturl, '"; | |
496 var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', '; | |
497 var smf_charset = "', $context['character_set'], '"; | |
498 | |
499 // Sets all ssi_preview class to hidden, then shows the one requested. | |
500 function showSSIBlock(elementID) | |
501 { | |
502 toggleVisibleByClass("ssi_preview", true); | |
503 document.getElementById(elementID).style.display = "block"; | |
504 } | |
505 | |
506 // Toggle visibility of all sections. | |
507 function toggleVisibleByClass(sClassName, bHide) | |
508 { | |
509 var oSections = document.getElementsByTagName("div"); | |
510 for (var i = 0; i < oSections.length; i++) | |
511 { | |
512 if (oSections[i].className == null || oSections[i].className.indexOf(sClassName) == -1) | |
513 continue; | |
514 | |
515 oSections[i].style.display = bHide ? "none" : "block"; | |
516 } | |
517 } | |
518 // ]]></script> | |
519 </head> | |
520 <body> | |
521 <div id="wrapper"> | |
522 <div id="header"><div class="frame"> | |
523 <div id="top_section"> | |
524 <h1 class="forumtitle">SMF 2.0 SSI.php Examples</h1> | |
525 <img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" /> | |
526 </div> | |
527 <div id="upper_section" class="middletext" style="overflow: hidden;"> | |
528 <div class="user"></div> | |
529 <div class="news normaltext"> | |
530 </div> | |
531 </div> | |
532 </div></div> | |
533 <div id="content_section"><div class="frame"> | |
534 <div id="main_content_section"> | |
535 <div id="liftup" class="flow_auto">'; | |
536 } | |
537 | |
538 function template_ssi_below() | |
539 { | |
540 global $time_start; | |
541 | |
542 echo ' | |
543 <script type="text/javascript"><!-- // --><![CDATA[ | |
544 showSSIBlock("ssi_recentTopics"); | |
545 // ]]></script> | |
546 </div> | |
547 </div> | |
548 </div></div> | |
549 <div id="footer_section"><div class="frame"> | |
550 <div class="smalltext"><a href="http://www.simplemachines.org">Simple Machines Forum</a></div> | |
551 </div></div> | |
552 </div> | |
553 </body> | |
554 </html>'; | |
555 } | |
556 | |
557 function template_homepage_sample1($method = 'source') | |
558 { | |
559 global $user_info, $boarddir; | |
560 | |
561 $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
562 <html xmlns="http://www.w3.org/1999/xhtml"> | |
563 <head> | |
564 <title>SSI.php example for home page</title> | |
565 <style type="text/css"> | |
566 body { font-family: Arial, Tahoma, sans-serif; font-size: 80%; background: #DFDFDF; color: #FFFFFF; margin: 0 } | |
567 ul,ol { padding-left: 19px; margin: 0; } | |
568 li { font-size: 11px; } | |
569 h1,h2,h3 { margin: 0; padding: 0; } | |
570 h3 { font-size: 15px; } | |
571 a:link,a:visited { color: #FF9000; text-decoration: none; } | |
572 a:hover { text-decoration: underline; } | |
573 | |
574 #container { background: #52514E; width: 100%; border: 1px solid midnightblue; line-height: 150%; margin: 0; } | |
575 #header,#footer { color: lightgray; background-color: #2A2825; clear: both; padding: .5em; } | |
576 #leftbar { background: #DF7E00; float: left; width: 160px; margin: 0; padding: 1em; } | |
577 #leftbar a { color: #000000; text-decoration: underline; } | |
578 #content { margin-left: 190px; padding: 1em; } | |
579 #navigation { float: right; } | |
580 #navigation a:link,#navigation a:visited { color: #FF9000; } | |
581 </style> | |
582 </head> | |
583 <body> | |
584 <div id="container"> | |
585 <div id="header"> | |
586 <div id="navigation"> | |
587 <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | |
588 </div> | |
589 <h1 class="header">YourWebsite.com</h1> | |
590 </div> | |
591 <div id="leftbar"> | |
592 <h3>Recent Forum Topics</h3> | |
593 <ul>'; | |
594 | |
595 $footer = ' | |
596 <div id="footer"> | |
597 <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/publicdomain/88x31.png" /></a> | |
598 This sample website layout is dedicated to the <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>. | |
599 </div> | |
600 </div> | |
601 </body> | |
602 </html>'; | |
603 | |
604 if ($method == 'source') | |
605 { | |
606 $header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header; | |
607 return $header . template_homepage_sample1_html() . $footer; | |
608 } | |
609 else | |
610 { | |
611 echo $header; | |
612 template_homepage_sample1_php(); | |
613 echo $footer; | |
614 } | |
615 | |
616 } | |
617 | |
618 function template_homepage_sample1_php() | |
619 { | |
620 global $txt; | |
621 | |
622 $topics = ssi_recentTopics(8, null, null, 'array'); | |
623 | |
624 foreach ($topics as $topic) | |
625 echo ' | |
626 <li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>'; | |
627 | |
628 unset($topics); | |
629 | |
630 echo ' | |
631 | |
632 </ul><br /> | |
633 | |
634 <h3>Online Users</h3>'; | |
635 ssi_logOnline(); | |
636 | |
637 echo ' | |
638 </div> | |
639 | |
640 <div id="content">'; | |
641 | |
642 ssi_welcome(); | |
643 echo ' | |
644 <br /><br /> | |
645 | |
646 <h2>News</h2>'; | |
647 | |
648 ssi_boardNews(); | |
649 | |
650 echo ' | |
651 </div>'; | |
652 | |
653 } | |
654 | |
655 function template_homepage_sample1_html() | |
656 { | |
657 $result = ' | |
658 <?php | |
659 // Using array method to show shorter display style. | |
660 $topics = ssi_recentTopics(8, null, null, \'array\'); | |
661 | |
662 foreach ($topics as $topic) | |
663 { | |
664 // Uncomment the following code to get a listing of array elements that SMF provides for this function. | |
665 // echo \'<pre>\', print_r($topic), \'</pre>\'; | |
666 | |
667 echo \' | |
668 <li><a href=\"\', $topic[\'href\'], \'\">\', $topic[\'subject\'], \'</a> \', $txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\'; | |
669 } | |
670 | |
671 unset($topics); | |
672 ?> | |
673 </ul><br /> | |
674 <h3>Online Users</h3> | |
675 <?php ssi_logOnline(); ?> | |
676 </div> | |
677 <div id="content"> | |
678 <?php ssi_welcome(); ?><br /><br /> | |
679 <h2>News</h2> | |
680 <?php ssi_boardNews(); ?> | |
681 </div>'; | |
682 | |
683 return $result; | |
684 } | |
685 | |
686 ?> |