The vB Geek

The vB Geek (http://www.thevbgeek.com/index.php)
-   Add-ons (http://www.thevbgeek.com/forumdisplay.php?f=16)
-   -   Latest Reply Module (Beta) (http://www.thevbgeek.com/showthread.php?t=998)

Lizard King 01-28-2006 03:51 PM

Latest Reply Module (Beta)
 
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 Code:

<?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'] !=$vbphrase['GARS_top_x'] : $vbphrase['GARS_top_none_x']), $vbphrase['GARS_top_' . ($settings['based'] ==  'read' : ($settings['based'] == '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'], nullfalsetrue);
    }
    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 07:44 PM

1 Attachment(s)
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 08:46 PM

Ill check into it tomorrow. Thanks :)

Lizard King 02-05-2006 01:45 PM

Quote:

Originally Posted by The Geek
Ill check into it tomorrow. Thanks :)

Any news :p

The Geek 02-05-2006 07: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 08: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 06:51 AM

module name? Im assuming you mean other than just saving it as another filename?

Lizard King 02-08-2006 03:53 PM

Quote:

Originally Posted by The Geek
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 07: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 ;)


All times are GMT. The time now is 08:10 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

Release powered by GARS 2.1.9 ©2005-2006