• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Add-on Need help about my simple add-on.

#1
Hi all,

I'm using xenForo and very interested in creating Add-on, but i'm a freshmen and know very few about xenForo Add-on developing. So I wrote here to need everyone help.

My add-on (in my head) is about a dropdown list can show news, announcements - and I called it is Release. It very simple, I input a title and a link, and it'll show in forum (below navbar), that's all.

But my problems start from how to integrate between database and template. I searched and it look like i'll use template hook, but i don't know how to use it... i viewed the video about this (made by Kier) but i'm confused :(

And another problem is about add new title and link via admincp (i input and they will list in the history in my add-on control)...

I'm really confused about this problems :( Please help me.
Thank you!
 
#3
This is my codes
<?php
class Horizon_Release_showEps
{
public function show()
{
$host='localhost';
$user='root';
$pass='';
$db='xfhor';
$con = mysql_connect($host,$user,$pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db, $con);

$sql = mysql_query("SELECT * FROM horizonrel ORDER BY id DESC");
while($row = mysql_fetch_array($sql))
{
echo $row['id'].' - '.$row['name'].' - '.$row['link'].'</br>';
}
mysql_close($con);
}
}
?>
I tried with PHP Callback, and it showed errors

An exception occurred: call_user_func() expects parameter 1 to be a valid callback, non-static method Horizon_Release_showEps::show() should not be called statically in F:\WAMP\www\xf113\library\XenForo\ViewAdmin\Helper\Option.php on line 327
  1. XenForo_Application::handlePhpError()
  2. call_user_func() in XenForo/ViewAdmin/Helper/Option.php at line 327
  3. XenForo_ViewAdmin_Helper_Option::_renderCallbackOptionHtml() in XenForo/ViewAdmin/Helper/Option.php at line 71
  4. XenForo_ViewAdmin_Helper_Option::renderPreparedOptionHtml() in XenForo/ViewAdmin/Helper/Option.php at line 33
  5. XenForo_ViewAdmin_Helper_Option::renderPreparedOptionsHtml() in XenForo/ViewAdmin/Option/ListOptions.php at line 30
  6. XenForo_ViewAdmin_Option_ListOptions->renderHtml() in XenForo/ViewRenderer/Abstract.php at line 215
  7. XenForo_ViewRenderer_Abstract->renderViewObject() in XenForo/ViewRenderer/HtmlAdmin.php at line 63
  8. XenForo_ViewRenderer_HtmlAdmin->renderView() in XenForo/FrontController.php at line 533
  9. XenForo_FrontController->renderView() in XenForo/FrontController.php at line 156
  10. XenForo_FrontController->run() in F:/WAMP/www/xf113/admin.php at line 13
Please help me thank you!