Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Create "Latest Threads" Custom Page
Princeton's Avatar
Princeton
Join Date: Nov 2001
Posts: 6,693

Joe Velez began developing for the web in 1998. He is an avid vBulletin user and volunteers his services as a vbulletin.org administrator. He currently spends his time maintaining and developing allnurses.com.

Vineland, NJ
Show Printable Version Email this Page Subscription
Princeton Princeton is offline 02-22-2006, 10:00 PM

A simple [HOWTO] to display latest threads on a custom page.

If you don't have GTCUSTOM PAGES installed .. go download and upload product via Plugin Manager. You need GTCUSTOM PAGES to follow this article.

LETS GET STARTED

INSTRUCTIONS:
  1. create 2 templates
  2. add 1 phrase
  3. add function to functions_gtcustom.php
  4. edit goto.php
  5. visit page at $vboptions[bburl]/goto.php?section=newthreads

1)__ CREATE 2 TEMPLATES
Create "custom_thread" template:

HTML Code:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
  <tbody>
    <tr>
      <td class="tcat" colspan="5"><a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('gtcthreads')"><img id="collapseimg_gtcthreads" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_gtcthreads].gif" alt="" border="0" /></a>$vbphrase[header_title]</td>
    </tr>
    <tr class="thead">
      <td>&nbsp;</td>
      <td class="smallfont" align="$stylevar[left]" width="100%">$vbphrase[thread] / $vbphrase[thread_starter]</td>
      <td class="smallfont" align="center" style="white-space:nowrap">$vbphrase[last_post]</td>
      <td class="smallfont" align="center">$vbphrase[replies]</td>
      <td class="smallfont" align="center">$vbphrase[views]</td>
    </tr>
  </tbody>
  <tbody id="collapseobj_gtcthreads" style="$vbcollapse[collapseobj_gtcthreads]">  
  $threadrows
  </tbody>  
</table>
<br />
Create "custom_threadrow" template:
HTML Code:
<tr>
	<td class="alt2" align="center"><if condition="$show['threadicon']"><img class="inlineimg" src="$thread[iconpath]" alt="" border="0" title="" /> <else />&nbsp;</if></td>
	<td class="alt1"><a href="showthread.php?t=$thread[threadid]"><strong>$thread[title]</strong></a>
		<div class="smallfont"> - by $thread[postusername]</div></td>
	<td class="alt2" align="center"><div class="smallfont time" style="white-space:nowrap">$thread[lastpostdate] $thread[lastposttime]<br />by $thread[lastposter]</div></td>
	<td class="alt1" align="center">$thread[replycount]</td>
	<td class="alt2" align="center">$thread[views]</td>
</tr>
2)__ CREATE 1 PHRASE
Phrase Type: GTCustom Pages
Product: GTCustom Pages
Varname: gtcustom_newthreads_header
Text: Latest Threads

3)__ ADD FUNCTION TO functions_gtcustom.php
Copy the following function to functions_gtcustom.php (functions_gtcustom.php is included in GTCUSTOM PAGES product)
PHP Code:
/* ==========[ PRINT LATEST THREAD ]===================================== */
/* ====================================================================== */
function print_gtcustom_newthreads()
{
    global 
$vbulletin$vbphrase$threadrows;
    
    
$threadarray $vbulletin->db->query_read("
        SELECT thread.*, icon.title AS icontitle, icon.iconpath
        FROM " 
TABLE_PREFIX "thread AS thread
        LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON(icon.iconid = thread.iconid)
        WHERE 
            thread.visible = 1
        ORDER BY dateline DESC 
        LIMIT 15"
);
    
    while(
$thread $vbulletin->db->fetch_array($threadarray))
    {
        if (
$thread['iconid'])
        {
            
// get icon from icon cache
            
$thread['iconpath'] = $vbulletin->iconcache["$thread[iconid]"]['iconpath'];
            
$thread['icontitle'] = $vbulletin->iconcache["$thread[iconid]"]['title'];
        }

        if (
$thread['pollid'] != 0)
        {
            
// show poll icon
            
$show['threadicon'] = true;
            
$thread['iconpath'] = "$stylevar[imgdir_misc]/poll_posticon.gif";
            
$thread['icontitle'] = $vbphrase['poll'];
        }
        else if (
$thread['iconpath'])
        {
            
// show specified icon
            
$show['threadicon'] = true;
        }
        else if (!empty(
$vbulletin->options['showdeficon']))
        {
            
// show default icon
            
$show['threadicon'] = true;
            
$thread['iconpath'] = $vbulletin->options['showdeficon'];
            
$thread['icontitle'] = '';
        }
        else
        {
            
// do not show icon
            
$show['threadicon'] = false;
            
$thread['iconpath'] = '';
            
$thread['icontitle'] = '';
        }
        
        
$thread['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], 1);
        
$thread['lastposttime'] = vbdate($vbulletin->options['timeformat'], $thread['lastpost']);
        eval(
'$threadrows .= "' fetch_template('custom_threadrow') . '";');
    }
    unset(
$threadarray);
    return 
$threadrows;

4)__ EDIT goto.php
FIND IN goto.php:
PHP Code:
        default;            
            eval(
'$HTML = "' fetch_template('custom_mypage') . '";'); 
REPLACE WITH:
PHP Code:
        case 'newthreads';
            
$threadrows print_gtcustom_newthreads();            
            eval(
'$HTML = "' fetch_template('custom_thread') . '";');            
            break;
        default;            
            eval(
'$HTML = "' fetch_template('custom_mypage') . '";'); 
FIND:
PHP Code:
if ($_REQUEST['section']=='sitemap')
{
    
$globaltemplates[] = 'custom_sitemap';

REPLACE WITH:
PHP Code:
switch($_REQUEST['section'])
{
    case 
'sitemap';
        
$globaltemplates[] = 'custom_sitemap';
        break;
    case 
'newthreads';
        
$specialtemplates[] = 'iconcache';
        
$globaltemplates array_merge($globaltemplates, array('custom_thread''custom_threadrow'));
        break;

5)__ DONE!
Now, go visit the page that you just created:
$vboptions[bburl]/goto.php?section=newthreads

Need any help? Contact me personally via private message.

NOTE:
  1. All html code is valid XHTML.
  2. This query will display all thread titles regardless of permission settings.
Attached Images
File Type: jpg newthreads.jpg (38.1 KB, 0 views)
Attached Files
File Type: txt latest_threads_function-1.txt (5.7 KB, 154 views)
Reply With Quote
  #12  
Old 03-17-2006, 10:11 PM
theguywhoknowz theguywhoknowz is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

K thanks but what if I want to show only 3,4 thread on the lastest thread, not 15 of them, how do i reduce the number of thread shown?
Reply With Quote
  #13  
Old 03-18-2006, 02:19 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit this line
PHP Code:
LIMIT 15 
to
PHP Code:
LIMIT 4 
Reply With Quote
  #14  
Old 03-20-2006, 04:17 PM
theguywhoknowz theguywhoknowz is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you, princton, it works liek a champ, now the problem is, what if i want to change the font and style on that custom thread page, cause it use the forum css and it is bigger than my custom page font and size, is there a way?
Reply With Quote
  #15  
Old 03-21-2006, 08:13 PM
theguywhoknowz theguywhoknowz is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nvm, i got this.
Reply With Quote
  #16  
Old 03-26-2006, 02:38 PM
ChrisBaktis ChrisBaktis is offline
 
Join Date: Mar 2004
Location: CT
Posts: 409
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im looking to use something like this but instead of threads I would like to list members in order of the highest number in a custom profile field....I run a trading site and each time a member makes a trade we add 1 point to a custom profile field...I want to start from highest to lowest and list the member and how many trades they have. Would this work and if so what would I need to change?
Reply With Quote
  #17  
Old 05-01-2006, 02:40 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ChrisBaktis
Im looking to use something like this but instead of threads I would like to list members in order of the highest number in a custom profile field....I run a trading site and each time a member makes a trade we add 1 point to a custom profile field...I want to start from highest to lowest and list the member and how many trades they have. Would this work and if so what would I need to change?
hi ChrisBaktis,
You will need to create the function and queries to do this ... once you have that you can add it to the GTCUSTOM PAGE product.
Reply With Quote
  #18  
Old 05-23-2006, 09:44 PM
Kriminal's Avatar
Kriminal Kriminal is offline
 
Join Date: Dec 2004
Location: Buenos Aires
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks!
Could you help me to add a column with the forum name where the threads belongs?
Reply With Quote
  #19  
Old 05-30-2006, 07:26 PM
theguywhoknowz theguywhoknowz is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do I have the hot topic thread to show or most active usersname instead of recent threads?
Reply With Quote
  #20  
Old 06-04-2006, 10:31 PM
Angeleyes Angeleyes is offline
 
Join Date: May 2006
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a "back room" on my pet forum where we discuss board/moderator issues. This will show those threads? Is there anyway to eliminate that?
Reply With Quote
  #21  
Old 06-04-2006, 10:35 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you will have to edit the script to fetch rows based on permissions
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05923 seconds
  • Memory Usage 2,382KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_html
  • (7)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete