PradoSoft

Simple Machines Forums with Creole tutorial

From PRADO Wiki

Back to the Cookbook

Using Creole with SMF

In this example i am pulling Events data from a Simple Machines Forum database and binding it into a TRepeater.

Events.page

 
<com:TContent ID="content">
<table border="0">
 <tr>
  <td valign="top" width="650px ">
   <com:TRepeater ID="EventData">
   <prop:ItemTemplate>
    <%#$this->DataItem['subject'] %> - <%#isset($this->DataItem['startdate']) ? strftime('%m/%d/%Y',strtotime($this->DataItem['startdate'])) : null %><br/>
    <%#$this->DataItem['body'] %>
   </prop:ItemTemplate>
   </com:TRepeater>
  </td>
 </tr>
</table>
</com:TContent>

Events.php

 
<?php
class Events extends TPage
{
	public function onLoad($param)
	{
		parent::onLoad($param);
		if (!$this->IsPostBack)
		{
			$sql = '
			SELECT 
				c.startDate, 
				m.subject, 
				m.body 
			FROM 
				smf_calendar AS c 
			INNER JOIN 
				smf_topics AS t USING(ID_TOPIC) 
			INNER JOIN 
				smf_messages AS m ON t.ID_FIRST_MSG = m.ID_MSG
			WHERE
				c.startDate >= NOW();';
 
			$conn = Creole::getConnection($this->Application->Parameters['smfDSN']);
			$this->EventData->DataSource = $conn->executeQuery($sql);
			$this->EventData->dataBind();
		}
	}
}
?>
Personal tools
Your user name:

Your password:

MediaWiki