vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Create "Latest Threads" Custom Page (https://vborg.vbsupport.ru/showthread.php?t=108725)

Princeton 02-22-2006 10:00 PM

Create "Latest Threads" Custom Page
 
1 Attachment(s)
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.

hiiped 02-23-2006 10:51 PM

nice work

thanks

Princeton 02-24-2006 12:26 AM

thanks for the feedback :up:

Clayton 02-27-2006 06:07 PM

hi princeton

some great work going on here

i would like to the latest threads from one website[domain] and display it on another domain, would it be possible to do it with this hack, please?

thank you

C

Princeton 02-27-2006 09:31 PM

try xml/rss/javascript syndication:
http://www.vbulletin.com/docs/html/v...group_external

justindwhite 03-02-2006 10:18 PM

Whats the best way to put the:
"$vboptions[bburl]/goto.php?section=newthreads" on your non vb page?

I've tried using iframe as you can see on http://www.h2survivor.com, but when you click on a link it loads in the iframe. Anyone know a better way to do this or fix the iframe problem?

Also, I notice on the preview image that all the posts say 7:00PM. On my site, it also has every post as being posted at 7:00PM. I can't seem to figure this out on my own.

Princeton 03-03-2006 01:27 AM

I made some changes..

IN gtcustom_threadrow replace
$thread[lastpost]
with
$thread[lastpostdate]

in the print_gtcustom_newthreads() replace
$thread['lastpost'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], 1);
with
$thread['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], 1);

regarding the iframe ...
add a target attribute to your link ie.
HTML Code:

target="new"

Clayton 03-03-2006 06:13 AM

thanks princeton

will wait a little longer to see the different changes and then attempt to create the page with the forum threads on

Thank you

C

theguywhoknowz 03-14-2006 09:24 PM

Ok so i was sucessful add the latest thread into a custom php page, but i resize the table, and the thread title is too long, it wrap down, is there a way that it only show the first 10 characters and the rest is "..." without wraping the text to the next line?

Princeton 03-15-2006 11:57 AM

try fetch_word_wrapped_string($title, $limit)


All times are GMT. The time now is 01:40 PM.

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.01517 seconds
  • Memory Usage 1,792KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_html_printable
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete