DB Queries on a Page

You will have to create a php callback and a method.
create your own add-on, create a class (which will be your callback) and a public function (your method).
You can have it then connect and query the database, and return $something;
You can then use that something in your page.
 

http://www.waywardinn.com/forum/#the-stage.5413
Is what we are trying to get working. It grabs the descriptions of forums under the category above. http://www.waywardinn.com/pages/testwizard/

As you can see, on the page the lists are not showing their banners, but it works on the actual script, http://www.waywardinn.com/testlist.php

Here is what we have for PHP Callback: Dev_PageCallback_TemplateDemo method: respond

The template has the following.

<xen:title>{$page.title}</xen:title>

<xen:navigation>
<xen:breadcrumb source="$nodeBreadCrumb" />
</xen:navigation>

<xen:require css="public.css" />

<div class="sectionMain">
<h2 class="sectionMain">Wayward Inn Roleplays</h2>
<ol>
<xen:foreach loop="$rps" value="$rp">
<li class="secondaryContent userThing">
<div class="userTitle">{$rp.title}</div>
<div class="userTitle">{$rp.description}</div>
</li>
</xen:foreach>
</ol>
</div>


Is there any reason as to why the page would not show the banners?
 
Can you post the PHP code for your callback (Dev_PageCallback_TemplateDemo::respond) and testlist.php file?


Callback TemplateDemo:

Code:
<?php
include("./dbmysql.php");
class Dev_PageCallback_TemplateDemo
{
    public static function respond(Xenforo_ControllerPublic_Abstract $controller, Xenforo_ControllerResponse_Abstract $response)
    {
$db = new dbMysql('localhost', 'Database Name', 'User', 'password', 'false');
$result = $db->query('SELECT b.title, b.description FROM xf_forum AS a INNER JOIN xf_node AS b ON(a.node_id = b.node_id) WHERE b.parent_node_id = 5413 ORDER BY b.title ASC');
$response->params['rps'] = $result;
$response->templateName = 'template_demo';
    }
}
?>

Testlist.php

Code:
<?php
 
include("./dbmysql.php");
$db = new dbMysql('localhost', 'Database Name', 'User', 'Password', 'false');
$result = $db->query('SELECT b.title, b.description FROM xf_forum AS a INNER JOIN xf_node AS b ON(a.node_id = b.node_id) WHERE b.parent_node_id = 5413 ORDER BY b.title ASC');
 
foreach($result as $a)
{
echo $a['title'] . '<br />' . $a['description'] . '<br /><br />';
}
 
?>
 
Top Bottom