its custom as well, ill dig up the code for you
Printable View
create a block in the forums block manager (same as you did before)
i called it: recent wiki changes
php
put the following code in the content.
you probably have to replace ALL the text with vb3_ with your own prefix code of your vbulletin tables
then create a new template in the style manager called: block_wikichangesCode:global $db, $vbphrase, $threadinfo, $post, $stylevar, $show;
$threads= $db->query_read_slave("
SELECT thread.title, thread.forumid, thread.threadid, revision.revisionid, revision.reason as reason,
revision.dateline, revision.username as postusername, thread.lastpost AS threadlastpost,
thread.lastposterid, forum.title_clean as forumtitle, user.*, avatar.avatarpath,
NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,
customavatar.width AS avwidth,customavatar.height AS avheight
FROM (
select * from `vb3_vault_revision` order by dateline DESC
) AS revision
LEFT JOIN vb3_thread AS thread ON (thread.threadid = revision.threadid)
INNER JOIN vb3_forum AS forum ON(forum.forumid = thread.forumid)
LEFT JOIN vb3_user AS user ON (user.userid = revision.userid)
LEFT JOIN vb3_avatar AS avatar ON(avatar.avatarid = user.avatarid)
LEFT JOIN vb3_customavatar AS customavatar ON(customavatar.userid = user.userid)
group by thread.title
order by revision.dateline DESC
LIMIT 10
");
while ($thread = $this->registry->db->fetch_array($threads))
{
//echo "title: ".$thread['title'] ."<br>";
// still need to censor the title
$thread['title'] = fetch_censored_text($thread['title']);
$thread['date'] = vbdate($this->registry->options['dateformat'], $thread['dateline'], true);
$thread['time'] = vbdate($this->registry->options['timeformat'], $thread['dateline']);
$thread['lastpostdate'] = vbdate($this->registry->options['dateformat'], $thread['threadlastpost'], true);
$thread['lastposttime'] = vbdate($this->registry->options['timeformat'], $thread['threadlastpost']);
// get avatar
$this->fetch_avatarinfo($thread);
$threadarray[$thread['threadid']] = $thread;
}
foreach ($threadarray as $key => $thread)
{
//echo "<br> - title: ". $threadarray[$key]['title'];
$threadarray[$key]['url'] = fetch_seo_url('thread', $thread);
$threadarray[$key]['newposturl'] = fetch_seo_url('thread', $thread, array('goto' => 'newpost'));
$threadarray[$key]['lastposturl'] = fetch_seo_url('thread', $thread, array('p' => $thread['lastpostid'])) .
'#post' . $thread['lastpostid'];
$threadarray[$key]['title'] = fetch_trimmed_title($thread['title'], $this->config['threads_titlemaxchars']);
}
$templater = vB_Template::create('block_wikichanges');
$templater->register('threads', $threadarray);
return $templater->render();
$db->free_result($threads);
unset($threadarray );
with the following code
then in the everywhere sidebar you can show hide it where ever you likeCode:<ul id="block_wikichanges_{vb:raw blockinfo.blockid}" >
<vb:each from="threads" key="threadid" value="thread">
<li class="<vb:if condition="!$vboptions['avatarenabled']">no</vb:if>avatarcontent floatcontainer widget_post_bit">
<div class="widget_post_userinfo">
<vb:if condition="$vboptions['avatarenabled']">
<div class="cms_widget_post_useravatar widget_post_useravatar">
<a class="smallavatar comments_member_avatar_link" href="{vb:link member, {vb:raw thread}}">
<vb:if condition="$thread['showavatar']">
<img width="30" title="" src="{vb:raw thread.avatarurl}" alt=""/>
<vb:else />
<img width="30" title="" src="{vb:stylevar imgdir_misc}/unknown.gif" alt=""/>
</vb:if>
</a>
</div>
</vb:if>
</div>
<div class="smallavatartext widget_post_comment<vb:if condition="!$vboptions['avatarenabled']">_noavatar</vb:if>">
<h5 class="widget_post_header"><a href="{vb:raw thread.url}" class="title">{vb:raw thread.title}</a></h5>
<div class="meta">
<vb:if condition="$threadstype == 0">Edited by <a href="{vb:link member, {vb:raw thread}}">{vb:raw thread.postusername}</a> {vb:stylevar dirmark}<vb:if condition="$thread['reason']"><br />(Reason: {vb:raw thread.reason})</vb:if>
<br />{vb:raw thread.date}<vb:if condition="!$show['detailedtime']">, <span class="time">{vb:raw thread.time}</span></vb:if> {vb:rawphrase in_x, {vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}, {vb:raw thread.forumtitle}}
<vb:else />
{vb:rawphrase last_post_by} <a href="{vb:link member, {vb:raw thread}, null, 'lastposterid', 'lastposter'}">{vb:raw thread.lastposter}</a> {vb:stylevar dirmark}({vb:rawphrase x_replies, {vb:raw thread.replycount}})
<br />
{vb:raw thread.lastpostdate}<vb:if condition="!$show['detailedtime']">, <span class="time">{vb:raw thread.lastposttime}</span></vb:if> {vb:rawphrase in_x, {vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}, {vb:raw thread.forumtitle}}
</vb:if>
</div>
</div>
</li>
</vb:each>
</ul>
that should do it
oh i put the cache time of the block on 60 minutes, so it doesnt run too often
That's a good idea, that query is expensive (it requires a full scan of a potentially large vault_revision table). If you break it up into two queries, you can perform the scan on a much smaller table.
Use the collected datelines to:Code:SELECT lastmodified AS dateline FROM vb3_vault_article WHERE pending = 0
Hope this helps; this is essentially how we build the Recent Changes page to avoid massive scans.Code:SELECT ... FROM vb3_vault_revision AS revision
...
WHERE revision.dateline IN (collected_datelines)
Also, if you can and know how to package product files, it would be great if you can release this as a mod in our modifications forum.
You guys rock. I'll play around with that tomorrow. I have my boy home from school for the Holiday, and my wife at work, so I might not get a chance to dig in, I'll let you know where I get with it!