Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2004, 05:51 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default adding replys (0) to custom script

I received this script from Turcic.com and I am modifing it to meet my needs for a new home page that I am working on!

you can see it in action here:

http://www.sportsrant.com/indexpost.php


I actually have it working great but I want to add one small feature!! the replies/comments that are posted to it in the forum that I am pulling this from: the "full story" works fine and goes to the forum post. I was wondering if someone could help me add the replies to it: here is the code:

PHP Code:
<?php
// +-------------------------------------------------------------+
// | Turcic.com Website index.htm
// | Copyright ?2003 Alexander Turcic
// | Date: 2003/09/29 00:00:00 - Revision: 4.00
// +-------------------------------------------------------------+
error_reporting(E_ALL);
chdir('upgrade/vb');
require_once(
'./global.php');
include(
"./glob/css.php");
csssite($pvlayer=0);

// #################### VB: DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('SESSION_BYPASS'1);
define('LOCATION_BYPASS'1);
define('DIE_QUIETLY'1);
define('THIS_SCRIPT''external');

// ################### VB: PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array(
    
'userstats',
    
'birthdays',
    
'maxloggedin'
);

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### VB: REQUIRE BACK-END ############################
//chdir('upgrade/vb');
require_once('./global.php');
require_once(
'./includes/functions_bbcodeparse.php');
//require_once('./includes/functions_external.php'); // seems not to be needed here
chdir('..');

// ############################################################################
// Get Header template
$page_title 'Welcome to Turcic.com!';
//include_once('./templates/header.php');

// ############################################################################
// connnect to custom database (not used so far)
// dbconnect(); 
// $result = dbquery("SELECT id, time, source, title, url, langid FROM links ORDER BY time DESC;") or die("MySQL Error: " . mysql_error());

// Here comes specific Page Content
?>

<?php
// set announcement forum id
global $index,$fontcolor1,$fontcolor2,$fontcolor3,$fontcolor4,$bgcolor1,$bgcolor2,$bgcolor3,$bgcolor4$title;
$announceforums "14";
$forumchoice = array();
$forumids explode(','$announceforums);
foreach (
$forumids AS $forumid)
{
    
$forumid intval($forumid);
    if (isset(
$forumcache["$forumid"]))
    {
        
$forumchoice[] = $forumid;
    }
}
if (!empty(
$forumchoice))
{
    
$forumchoice 'AND thread.forumid IN(' implode(','$forumchoice) . ')';
}
else
{
    
$forumchoice '';
}

// if unlogged, set us up as a very limited privileges user
if (!$bbuserinfo['userid'])
{
    
$vboptions['hourdiff'] = (date('Z'TIMENOW) / 3600 intval($_REQUEST['timeoffset'])) * 3600;
    
$bbuserinfo = array('usergroupid' => 1);
    
$usergroupcache = array();
    
$permissions cache_permissions($bbuserinfo);
}

// get visible forums for this user
$forumids = array();
foreach (
array_keys($forumcache) AS $forumid)
{
    
$fp = &$bbuserinfo['forumpermissions']["$forumid"];
    if (
$fp CANVIEW AND $fp CANVIEWOTHERS)
    {
        
$forumids[] = $forumid;
    }
}

$previewfield "post.pagetext AS preview,";
$previewjoin "LEFT JOIN " TABLE_PREFIX "post AS post ON(post.postid = thread.firstpostid)";

// query last 15 threads from visible / chosen forums
$threads $DB_site->query("
    SELECT 
$previewfield
        thread.threadid, thread.title, thread.lastposter, thread.lastpost, thread.postusername, thread.dateline, forum.forumid, forum.title AS forumtitle
    FROM " 
TABLE_PREFIX "thread AS thread
    
$previewjoin
    INNER JOIN " 
TABLE_PREFIX "forum AS forum ON(forum.forumid = thread.forumid)
    LEFT JOIN " 
TABLE_PREFIX "deletionlog AS deletionlog ON (deletionlog.primaryid = thread.threadid AND deletionlog.type = 'thread')
    WHERE thread.forumid IN(" 
implode(','$forumids) . ") $forumchoice
        AND thread.visible = 1
        AND deletionlog.primaryid IS NULL
    ORDER BY thread.dateline DESC
    LIMIT 5
"
);

$threadcache = array();
while (
$thread $DB_site->fetch_array($threads))
// fetch the threads
    
$threadcache[] = $thread;
}

if (!empty(
$threadcache))
{
    foreach (
$threadcache AS $thread)
    {

         
         
$thread['preview'] = strip_quotes($thread['preview']);
         
//$thread['preview'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbcode($thread['preview'], true, true),1500));
         
$thread['preview'] = fetch_trimmed_title(strip_bbcode($thread['preview'], truetrue),1500);
         echo 
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
         echo 
"<tr>";
         echo 
"<td class=\"title\" align=\"center\">$thread[title]<br></font></td></tr>\n";
         echo 
"<tr>";
         echo 
"<td class=\"title\" align=\"right\">" vbdate('M d, Y'$thread['dateline']) . " </font></td>\n";
         echo 
"</tr>";
         echo 
"<tr>";
         echo 
"<td class=\"content\">$thread[preview]</td></tr>";
         echo 
"<tr>";
         echo 
"<td class=\"content\"><a target=\"_blank\" href=\"upgrade/vb/showthread.php?t=$thread[threadid]\"><br>(Full Story</a>, Comments )<br><br><br><hr></td>";
         echo 
" </tr></table>";
    }
}

?>
this is the actual line that shows the "full Story" link

PHP Code:
echo "<td class=\"content\"><a target=\"_blank\" href=\"upgrade/vb/showthread.php?t=$thread[threadid]\"><br>(Full Story</a>, Comments )<br><br><br><hr></td>"
AND the actual data coming from the database.....
PHP Code:
$threads $DB_site->query("
    SELECT 
$previewfield
        thread.threadid, thread.title, thread.lastposter, thread.lastpost, thread.postusername, thread.dateline, forum.forumid, forum.title AS forumtitle
    FROM " 
TABLE_PREFIX "thread AS thread
    
$previewjoin
    INNER JOIN " 
TABLE_PREFIX "forum AS forum ON(forum.forumid = thread.forumid)
    LEFT JOIN " 
TABLE_PREFIX "deletionlog AS deletionlog ON (deletionlog.primaryid = thread.threadid AND deletionlog.type = 'thread')
    WHERE thread.forumid IN(" 
implode(','$forumids) . ") $forumchoice
        AND thread.visible = 1
        AND deletionlog.primaryid IS NULL
    ORDER BY thread.dateline DESC
    LIMIT 5 

ANYONE!!!!!!
Reply With Quote
  #2  
Old 01-20-2004, 06:04 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am not sure what you want exactly ...
Do you 1) want to show the whole thread at this page or 2) do you want to have reply-functionality?
For 2)
PHP Code:
 echo "<td class=\"content\"><a target=\"_blank\" href=\"upgrade/vb/showthread.php?t=$thread[threadid]\"><br>(Full Story</a>, Comments [<a href=href=\"upgrade/vb/newreply.php?do=newreply&noquote=1&t=$thread[threadid]\">Comment this</a>])<br><br><br><hr></td>"
instead of the original one might do the trick (if your users are allowed to post replies in the forum(s) the thread(s) come from.

Or do you want smth. completely different?
Reply With Quote
  #3  
Old 01-20-2004, 06:13 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I want to have that ability and right next to that show the number of replies in (3) [example]. is that something that can be done
Reply With Quote
  #4  
Old 01-20-2004, 06:23 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Replace

PHP Code:
    $threads $DB_site->query("
       SELECT 
$previewfield
         thread.threadid, thread.title, thread.lastposter, thread.lastpost, thread.postusername, thread.dateline, forum.forumid, forum.title AS forumtitle 
With
PHP Code:
    $threads $DB_site->query("
       SELECT 
$previewfield
         thread.replycount, thread.threadid, thread.title, thread.lastposter, thread.lastpost, thread.postusername, thread.dateline, forum.forumid, forum.title AS forumtitle 
Replace
PHP Code:
 echo "<td class=\"content\"><a target=\"_blank\" href=\"upgrade/vb/showthread.php?t=$thread[threadid]\"><br>(Full Story</a>, Comments )<br><br><br><hr></td>"
With
PHP Code:
 echo "<td class=\"content\"><a target=\"_blank\" href=\"upgrade/vb/showthread.php?t=$thread[threadid]\"><br>(Full Story</a>, $thread[replycount] Comments [<a href=href=\"upgrade/vb/newreply.php?do=newreply&noquote=1&t=$thread[threadid]\">Comment this</a>])<br><br><br><hr></td>"
This should give you an output like

(Full story, 3 Comments [Comment this])
Reply With Quote
  #5  
Old 01-20-2004, 06:36 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i added your code and I am getting this in the bottom!

(Full Story, Array{replycount] Comments [Comment this])

any ideas!!!
Reply With Quote
  #6  
Old 01-20-2004, 06:37 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nevermind, it was "{" and should be "[", thanks so much
Reply With Quote
  #7  
Old 01-20-2004, 06:44 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

man thanks so much, that is great. I really appreciate the help, I just could not figure it out
Reply With Quote
  #8  
Old 01-20-2004, 06:57 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by msimonds
nevermind, it was "{" and should be "[", thanks so much
Argh, was just a typo
Reply With Quote
  #9  
Old 01-20-2004, 07:10 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no problem man, I do it more than anyone
Reply With Quote
  #10  
Old 01-20-2004, 07:29 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey man I am going to ask one more favor........ What about adding one more call to the DB to see who actually posted the article...... Like:

story....................

Written By: (username)
(Full Story...., Comments (2))
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 04:28 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07666 seconds
  • Memory Usage 2,327KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete