PDA

View Full Version : Latest Reply Module (Beta)


Lizard King
01-28-2006, 02: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]&amp;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);
}
?>

Lizard King
01-28-2006, 06:44 PM
Geek can you also explain me what i did wrong ?

the first lastpost.php worked at the beginning but when i add the module in another gars defined forum it couldn't get the settings. then i tried with the other one but it messed up the settings all the way :p

The Geek
01-29-2006, 07:46 PM
Ill check into it tomorrow. Thanks :)

Lizard King
02-05-2006, 12:45 PM
Ill check into it tomorrow. Thanks :)
Any news :p

The Geek
02-05-2006, 06:16 PM
Thanks for the reminder Lizard... however I cant really see anything wrong with this. What problem are you having?

Lizard King
02-05-2006, 07:31 PM
The first one works perfect but the module name is the problem. I couldn't find a way to change the module name when i choose latest replies :)

The Geek
02-06-2006, 05:51 AM
module name? Im assuming you mean other than just saving it as another filename?

Lizard King
02-08-2006, 02:53 PM
module name? Im assuming you mean other than just saving it as another filename?
The one i am using is the modified top.php which is in the first post.

The Geek
02-08-2006, 06:16 PM
Sure, but im not following you (either too much or too little caffine!)

What exactly is the problem? Cant you just save it as 'mynewmodule.php' and register it accordingly? Thats why I think im not following you ;)