DivinoZarathos
07-15-2012, 04:33 PM
Hi all! I'm trying to create a random quote plugin for my board's header.
So far, i created the following plugin on global_bootstrap_init_start:
if ($result = $vbulletin->db->query_first
("
SELECT text, author
FROM " . TABLE_PREFIX . "cs_randomquotes
WHERE approved = 1
ORDER BY RAND() LIMIT 1
")
)
{
$templater = vB_Template::create('header_randomquote');
$templater->register('author', $result['author']);
$templater->register('text', $result['text']);
$randomquote = $templater->render();
}
else
$randomquote = '';
vB_Template::preRegister('header', array('randomquote' => $randomquote));
Then I created the header_randomquote template:
<div class="text">{vb:raw text}</div>
<vb:if condition="$author">
<div class="author">{vb:raw author}</div>
</vb:if>
And I finally edited my header template adding:
<div id="header_randomquote">{vb:raw randomquote}</div>
Query is ok (well, I think it's ok to get random entries)... but nothing is being shown. Can you find any error in my code? :S
So far, i created the following plugin on global_bootstrap_init_start:
if ($result = $vbulletin->db->query_first
("
SELECT text, author
FROM " . TABLE_PREFIX . "cs_randomquotes
WHERE approved = 1
ORDER BY RAND() LIMIT 1
")
)
{
$templater = vB_Template::create('header_randomquote');
$templater->register('author', $result['author']);
$templater->register('text', $result['text']);
$randomquote = $templater->render();
}
else
$randomquote = '';
vB_Template::preRegister('header', array('randomquote' => $randomquote));
Then I created the header_randomquote template:
<div class="text">{vb:raw text}</div>
<vb:if condition="$author">
<div class="author">{vb:raw author}</div>
</vb:if>
And I finally edited my header template adding:
<div id="header_randomquote">{vb:raw randomquote}</div>
Query is ok (well, I think it's ok to get random entries)... but nothing is being shown. Can you find any error in my code? :S