Lizard King
01-28-2006, 03:51 PM
I was missing latest replies module as i usually want my gars defined forums alphabatically listed.
I requested from Geek but he is on holiday right now :) so i tried to create one . I managed to add the module and even i managed to get the threads and then i messed up something :P but i managed to get it working then again it caused me a problem.
Then after trying several solutions i found the easist way is to modify top.php
Here is the modified top.php but i couldn't find a solution how to change module name :p
<?php
$custom_top_based = array('1'=>$vbphrase['GARS_top_read'], '2'=> $vbphrase['GARS_top_active'], '3'=> $vbphrase['GARS_top_latest'], '4'=>'Latest Replies');
if ($stage == "display")
{
$title = construct_phrase(($settings['based'] !=3 ? $vbphrase['GARS_top_x'] : $vbphrase['GARS_top_none_x']), $vbphrase['GARS_top_' . ($settings['based'] == 1 ? 'read' : ($settings['based'] == 2 ? 'active' : 'latest'))], $this->terms['capital_plural']);
$items = $this->fetch_module_cache($itemid);
if (!is_array($items))
{
if (is_array($this->settings['forums']) || is_array($settings['forums']))
{
if (is_array($settings['forums']) && $settings['pull'])
{
foreach($settings['forums'] as $value)
{
$forumids .= ",$value";
}
}
else
{
foreach($this->settings['forums'] as $key1=>$value1)
{
if ($value1 == $this->typeid)
{
$forumids .= ",$key1";
}
}
}
if ($forumids)
{
switch ($settings['based'])
{
case '1':
$orderby = "ORDER BY t.views DESC";
break;
case '2':
$orderby = "ORDER BY t.replycount DESC";
break;
case '3':
$orderby = "ORDER BY t.dateline DESC";
break;
case '4':
$orderby = "ORDER BY t.lastpost DESC";
break;
}
$limit = intval($settings['limit']);
$results = $this->db->query_read("SELECT t.title, t.views, t.replycount, t.threadid, t.lastpost FROM " . TABLE_PREFIX . "thread t WHERE t.forumid in (-1$forumids) AND t.visible=1 $orderby LIMIT " . (intval($limit) ? $limit : "5"));
$items = array();
while ($result = $this->db->fetch_array($results))
{
$items[] = $result;
}
$this->cache_module($itemid, $items);
unset($result, $results, $info, $ids);
$this->db->free_result($results);
}
}
}
if (is_array($items))
{
$bits = "";
foreach ($items as $value)
{
$bits .= "<tr><td class='alt2' align='left'><a href='showthread.php?t=$value[threadid]&goto=newpost' title='$value[title]'>$value[title]</a></td></tr>";
}
if ($bits)
{
$bits = "<tr><td class='alt1' align='left'><table border='0' cellspacing='2' cellpadding='5' width='100%'>$bits</table></td></tr>";
eval('$output .="' . fetch_template('GARS_mod_container') . '";');
}
}
}
elseif($stage == "persist")
{
$this->cache_item_refresh($itemid);
}
elseif($stage == "settings")
{
$pulltype = array(
'0' => $vbphrase['GARS_pull_forums_same_type'],
'1' => $vbphrase['GARS_pull_forums_selected']);
print_description_row($vbphrase['GARS_top_desc']);
print_input_row($vbphrase['GARS_top_max'], "custom_top_limit[$itemid]", $settings['limit']);
print_select_row($vbphrase['GARS_top_based'], "custom_top_based[$itemid]", $custom_top_based, $settings['based']);
print_select_row($vbphrase['GARS_pull_forums_from'], "custom_top_pulltype[$itemid]", $pulltype, $settings['pull']);
print_forum_chooser ("", "custom_forums[$itemid][]", $settings['forums'], null, false, true);
}
elseif($stage == "persistsettings")
{
global $vbulletin;
$vbulletin->input->clean_array_gpc('p',array(
'custom_top_limit' => TYPE_ARRAY_ARRAY_INT,
'custom_top_based' => TYPE_ARRAY_ARRAY_INT,
'custom_top_pulltype' => TYPE_ARRAY_ARRAY_INT,
'custom_forums' => TYPE_ARRAY_ARRAY_INT
));
$settings['limit'] = $vbulletin->GPC['custom_top_limit'][$itemid];
$settings['based'] = $vbulletin->GPC['custom_top_based'][$itemid];
$settings['pull'] = $vbulletin->GPC['custom_top_pulltype'][$itemid];
$settings['forums'] = $vbulletin->GPC['custom_forums'][$itemid];
$this->cache_item_refresh($itemid,9);
}
?>
I requested from Geek but he is on holiday right now :) so i tried to create one . I managed to add the module and even i managed to get the threads and then i messed up something :P but i managed to get it working then again it caused me a problem.
Then after trying several solutions i found the easist way is to modify top.php
Here is the modified top.php but i couldn't find a solution how to change module name :p
<?php
$custom_top_based = array('1'=>$vbphrase['GARS_top_read'], '2'=> $vbphrase['GARS_top_active'], '3'=> $vbphrase['GARS_top_latest'], '4'=>'Latest Replies');
if ($stage == "display")
{
$title = construct_phrase(($settings['based'] !=3 ? $vbphrase['GARS_top_x'] : $vbphrase['GARS_top_none_x']), $vbphrase['GARS_top_' . ($settings['based'] == 1 ? 'read' : ($settings['based'] == 2 ? 'active' : 'latest'))], $this->terms['capital_plural']);
$items = $this->fetch_module_cache($itemid);
if (!is_array($items))
{
if (is_array($this->settings['forums']) || is_array($settings['forums']))
{
if (is_array($settings['forums']) && $settings['pull'])
{
foreach($settings['forums'] as $value)
{
$forumids .= ",$value";
}
}
else
{
foreach($this->settings['forums'] as $key1=>$value1)
{
if ($value1 == $this->typeid)
{
$forumids .= ",$key1";
}
}
}
if ($forumids)
{
switch ($settings['based'])
{
case '1':
$orderby = "ORDER BY t.views DESC";
break;
case '2':
$orderby = "ORDER BY t.replycount DESC";
break;
case '3':
$orderby = "ORDER BY t.dateline DESC";
break;
case '4':
$orderby = "ORDER BY t.lastpost DESC";
break;
}
$limit = intval($settings['limit']);
$results = $this->db->query_read("SELECT t.title, t.views, t.replycount, t.threadid, t.lastpost FROM " . TABLE_PREFIX . "thread t WHERE t.forumid in (-1$forumids) AND t.visible=1 $orderby LIMIT " . (intval($limit) ? $limit : "5"));
$items = array();
while ($result = $this->db->fetch_array($results))
{
$items[] = $result;
}
$this->cache_module($itemid, $items);
unset($result, $results, $info, $ids);
$this->db->free_result($results);
}
}
}
if (is_array($items))
{
$bits = "";
foreach ($items as $value)
{
$bits .= "<tr><td class='alt2' align='left'><a href='showthread.php?t=$value[threadid]&goto=newpost' title='$value[title]'>$value[title]</a></td></tr>";
}
if ($bits)
{
$bits = "<tr><td class='alt1' align='left'><table border='0' cellspacing='2' cellpadding='5' width='100%'>$bits</table></td></tr>";
eval('$output .="' . fetch_template('GARS_mod_container') . '";');
}
}
}
elseif($stage == "persist")
{
$this->cache_item_refresh($itemid);
}
elseif($stage == "settings")
{
$pulltype = array(
'0' => $vbphrase['GARS_pull_forums_same_type'],
'1' => $vbphrase['GARS_pull_forums_selected']);
print_description_row($vbphrase['GARS_top_desc']);
print_input_row($vbphrase['GARS_top_max'], "custom_top_limit[$itemid]", $settings['limit']);
print_select_row($vbphrase['GARS_top_based'], "custom_top_based[$itemid]", $custom_top_based, $settings['based']);
print_select_row($vbphrase['GARS_pull_forums_from'], "custom_top_pulltype[$itemid]", $pulltype, $settings['pull']);
print_forum_chooser ("", "custom_forums[$itemid][]", $settings['forums'], null, false, true);
}
elseif($stage == "persistsettings")
{
global $vbulletin;
$vbulletin->input->clean_array_gpc('p',array(
'custom_top_limit' => TYPE_ARRAY_ARRAY_INT,
'custom_top_based' => TYPE_ARRAY_ARRAY_INT,
'custom_top_pulltype' => TYPE_ARRAY_ARRAY_INT,
'custom_forums' => TYPE_ARRAY_ARRAY_INT
));
$settings['limit'] = $vbulletin->GPC['custom_top_limit'][$itemid];
$settings['based'] = $vbulletin->GPC['custom_top_based'][$itemid];
$settings['pull'] = $vbulletin->GPC['custom_top_pulltype'][$itemid];
$settings['forums'] = $vbulletin->GPC['custom_forums'][$itemid];
$this->cache_item_refresh($itemid,9);
}
?>