Jaxel
Well-known member
If you have a forum, with a lot of moderators, chances are moderators are designated to individual forums. Unfortunately, right now XenForo has no way to show the moderators for a specific forum, on that forum... So I have done it using hooks on my forum...
I do all customization on my forum to a product called "EWRcustom", its basically an Add-On that I don't release to the public, which contains all my custom settings and changes. This add-on has things like my sub forum grid listing, advert placements, thread sticky separations, user ribbons, etc. There are many hooks, custom models, listeners etc in this custom add-on of mine, but I will not be releasing the most of them to the public.
Today I just added "forum moderators" to this product and now I will show you how...
Below is my listener class: (I have removed other modifications from this class for this tutorial)
This is pretty simple... first it precaches a custom template called "EWRcustom_forum_view_pagenav_before". Then it looks for the hook 'forum_view_pagenav_before' which is inside the master template "forum_view". When it finds that template, it instantiates that moderator model, sends the node_id as a condition and fetches all the mdoerators for that forum. Then it builds the custom template and appends it to the hook.
Next I create that custom template "EWRcustom_forum_view_pagenav_before".
Then, simply create the two code event listeners in your AdminCP (I will not write a tutorial on how to do this as there are already several on this forum) and your moderators will be listed!
Example: http://www.8wayrun.com/forums/new-player-arena.92/
I do all customization on my forum to a product called "EWRcustom", its basically an Add-On that I don't release to the public, which contains all my custom settings and changes. This add-on has things like my sub forum grid listing, advert placements, thread sticky separations, user ribbons, etc. There are many hooks, custom models, listeners etc in this custom add-on of mine, but I will not be releasing the most of them to the public.
Today I just added "forum moderators" to this product and now I will show you how...
Below is my listener class: (I have removed other modifications from this class for this tutorial)
Code:
<?php
class EWRcustom_Listener_Template
{
public static function template_create($templateName, array &$params, XenForo_Template_Abstract $template)
{
switch ($templateName)
{
case 'forum_view':
$template->preloadTemplate('EWRcustom_forum_view_pagenav_before');
break;
}
}
public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
{
switch ($hookName)
{
case 'forum_view_pagenav_before':
{
$modModel = XenForo_Model::create('XenForo_Model_Moderator');
$conditions = array('content' => array('node', $hookParams['forum']['node_id']));
$hookParams['moderators'] = $modModel->getContentModerators($conditions);
$hookParams['modCount'] = count($hookParams['moderators']);
$contents .= $template->create('EWRcustom_forum_view_pagenav_before', $hookParams);
break;
}
}
}
}
Next I create that custom template "EWRcustom_forum_view_pagenav_before".
Code:
<xen:if is="{$modCount}">
<style type="text/css">.pageContent { position: relative; }</style>
<div class="sectionMain" style="position: absolute; top: 45px; right: 20px;">
<b>{xen:phrase moderators}:</b>
<xen:foreach loop="$moderators" value="$moderator" i="$i">
<a href="{xen:link members, $moderator}" class="username">{$moderator.username}</a><xen:if is="{$i} < {$modCount}">,</xen:if>
</xen:foreach>
</div>
</xen:if>
Then, simply create the two code event listeners in your AdminCP (I will not write a tutorial on how to do this as there are already several on this forum) and your moderators will be listed!
Example: http://www.8wayrun.com/forums/new-player-arena.92/