Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 08-23-2000 Last Update: Never Installs: 0
 
No support by the author.

Okay i thought i'd start a new thread ... how did tech talk do the today's active topics code hack to include it on a non vb page..

i have added most of the includes that tech talk released on my test index page at

now all i am missing are

1. active topics includes
2. displaying total threads
3. displaying total posts
4. displaying total registered members
5. displaying most recent registered member

any help is appreciated


[Edited by eva2000 on 01-04-2001 at 12:43 PM]

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 12-15-2000, 03:20 AM
Guest
 
Posts: n/a
Default

With a little trial-and-error, I've answered my own question. I wrote a little if-else statement that tests if the iconid is 0, and if it is, returns an empty string to a new variable; if it is not 0, an image tag is returned to the new variable.

I also noticed that, at least in Saracen's version, it has a bit at the bottom that is a hyperlink to the thread. The link says "xx comments...", where xx is the number of comments. What I didn't like is that it always says "comments", even if the number is 1, so it would read "1 comments...". I could have changed it to "comment(s)", but I went for a more sophisticated approach. Again, I wrote a little if-else statement, that tests if the number of replies is 1, and if so, returns the text "reply" to a new variable. If it isn't 1, it returns the text "replies" to the new variable. (I changed the word "comment" or "comments" to "reply" or "replies", for my own personal preference.)

You can see how both these work below. Note that this has pretty much no formatting, but thanks to Saracen's use of defining variables and calling them in the generated HTML, it is much easier to add whatever formatting you want.

Code:
<? 
include("/home/jjr512/jjr512-www/bbs/global.php");

$num_active = 7; 
$num_chars = 125;

$db=mysql_connect($servername,$dbusername,$dbpassword); 
mysql_select_db($dbname); 

$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='8' OR forumid='11' OR forumid='12' OR forumid='13' ORDER BY lastpost DESC LIMIT $num_active"; 

$resultlatest = mysql_query($querylatest,$db); 

while ($latest_array = mysql_fetch_array($resultlatest)) { 


// Get Forum Infomation 
$query_forum = "select * from forum where forumid='$latest_array[forumid]'"; 
$result_forum = mysql_query($query_forum,$db); 
$forum_info_array = mysql_fetch_array($result_forum); 

// split the date up a bit 
$datestr1 = substr($latest_array["dateline"],0,10); 
$datetime = substr($latest_array["dateline"],11,8); 

$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1"; 

$result_thread_text= mysql_query($querythread,$db); 

$result_thread_array = mysql_fetch_array($result_thread_text); 

$newstitle = $latest_array["title"]; 
$newsposter = $latest_array["postusername"]; 
$newsposterid = $result_thread_array["userid"]; 
$newsdate = date("D j M Y", $latest_array["dateline"]); 
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"]; 
$newscomments = $latest_array["replycount"]; 
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];

if ($threadiconid==0) {
 $threadicon = "";
 }
else {
 $threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\">?";
 }

if ($newscomments==1) {
 $commenttext = "reply ?";
 }
else {
 $commenttext = "replies ?";
 }

print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$threadicon$newstitle</b></font><br>"); 
print("<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Posted in <a href=\"http://www.jjr512.com/bbs/forumdisplay.php?forumid=$threadforumid\">$threadforum</a> by 
<a href=\"http://www.jjr512.com/bbs/member.php?action=mailform&userid=$newsposterid\">$newsposter</a> on $newsdate:
<br>\"$newstext...\"<br><a href=\"http://www.jjr512.com/bbs/showthread.php?threadid=$newsthreadid 
\">$newscomments $commenttext</a></font></br></p>"); 
} 

?>
(Note that in the first if-else statement, the one about the icons, in the else section, between the end of the image tag and the "; where it look like there's a space, it was really the HTML non-breaking space command, but I guess it got interpreted for some reason, rather than displayed literally.)

This is my first real attempt at making such big changes to a hack for php/mysql. If anyone has any suggestions on improving what I did, I'd love to hear them!

[Edited by JJR512 on 12-15-2000 at 12:24 AM]
Reply With Quote
  #53  
Old 12-15-2000, 04:45 AM
Guest
 
Posts: n/a
Default

Well, although that runs fine when I run the file activetopics.php by itself, I seem to be having trouble including it. Sacremen, I stuck that include statement at the top of the main file, tried it various other places, tried it inside the activetopics.php file. I tried it with full absolute path, relative path, or URL to the file global.php. I always seem to get the "Warning: Supplied argument not a valid etc.".

If I put it anywhere inside the activetopics.php file, I get the msg "Warning: Cannot add header information - header already sent etc.".

I've also tried it both with the path in the include statement, or with the separate line with the chdir statement.

Obviously, I'm missing something. Can you explain it to me, please? Thanks!
Reply With Quote
  #54  
Old 12-15-2000, 10:58 AM
Guest
 
Posts: n/a
Default

Could somebody help me make 2 hacks like the one's TechTalk made earlier in this thread?

1 for showing the current active users (xx members online... xx guests online...)

& 1 for checking if the user has logged in or not, if logged in, then show the "welcome back _____", if not, then show the log in text boxes.

Please & thanks a lot
Reply With Quote
  #55  
Old 12-15-2000, 11:23 PM
Guest
 
Posts: n/a
Default

LOL JJr...you tried too hard with that.....I just made a 1x1 pixel transparent gif and named it icon0.gif and uploaded it into the images/icons folder.
Reply With Quote
  #56  
Old 12-16-2000, 12:12 AM
Guest
 
Posts: n/a
Default

I considered that option, but decided against it. The reason was that, no matter what size you made the transparent icon, the size of the icon is defined in the image tag, so it gets stretched to full icon size. Well, you might say that doesn't matter, since it's transparent. True, but you do see an empty space. With the way I did it, if there is no icon, the text aligns to the edge of the table cell, rather than to the edge of an empty space. In my opinion, it just looks better.

But I'm still looking for help with the include global.php statement!
Reply With Quote
  #57  
Old 12-16-2000, 12:39 AM
Guest
 
Posts: n/a
Default

funny, it didn't on our page did it? http://www.friendswithoutfaces.com I don't see blank space where a posting icon would be. We're having trouble with the includes for top 25 posters, too. I can't seem to get it to work. But Kathy's already asked that question. <G>
Reply With Quote
  #58  
Old 12-16-2000, 12:43 AM
Guest
 
Posts: n/a
Default



Just call me desparate. I want that TOP 25 POSTERS list on my main page. I think a little competition and reward is a good thing to help encourage posting.... maybe? :lol:

Someone help us out?
Reply With Quote
  #59  
Old 12-16-2000, 07:27 AM
Guest
 
Posts: n/a
Default

OK, I've gotten the results to show up. Now I have another question, about long text strings breaking the tables. Since I have this hack displaying in a table that is only 155 pixels wide, this can be a problem with even a simple URL. Is there a way to force it to split a line apart rather than let the table get wider?
Reply With Quote
  #60  
Old 12-16-2000, 11:27 AM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by Kathy


Just call me desparate. I want that TOP 25 POSTERS list on my main page. I think a little competition and reward is a good thing to help encourage posting.... maybe? :lol:

Someone help us out?

I dont know the answer but sure hope you get one, I figured I asked enough questions so I wasnt going to ask - I just could not get teh dang thing to work.

But if I took the hack for most posts in the last 24 hours it worked fine, and you can change the time to go back a long times and giving you the same results as the top 25 hack - BUT in my case I cant use it because of a wierd glitch somewhere I had to prune a lot of messages and it will not count pruned messages in the persons post count.
Reply With Quote
  #61  
Old 12-17-2000, 08:45 AM
Guest
 
Posts: n/a
Default

OK, I've gotten it all worked out, with much help from Menno! This time, with the part that Menno added, if there is a URL that is so long that it would stretch the table, you don't have to worry. The part by Menno looks in the message text that would be displayed, and looks for the URL tags, and if it sees it, replaces the text of the hyperlink with the text (hyperlink). For an example, please look at my working test file, http://www.jjr512.com/newer.html

Code:
<?

$num_active = 6; 
$num_chars = 75;

$db=mysql_connect($servername,$dbusername,$dbpassword); 

mysql_select_db($dbname); 


$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='8' OR forumid='11' OR forumid='12' OR forumid='13' ORDER BY lastpost DESC LIMIT $num_active"; 

$resultlatest = mysql_query($querylatest,$db); 

while ($latest_array = mysql_fetch_array($resultlatest)) { 

// Get Forum Infomation 
$query_forum = "select * from forum where forumid='$latest_array[forumid]'"; 
$result_forum = mysql_query($query_forum,$db); 
$forum_info_array = mysql_fetch_array($result_forum); 

// split the date up a bit 
$datestr1 = substr($latest_array["dateline"],0,10); 
$datetime = substr($latest_array["dateline"],11,8); 

$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1"; 

$result_thread_text= mysql_query($querythread,$db); 

$result_thread_array = mysql_fetch_array($result_thread_text); 

$newstitle = $latest_array["title"]; 
$newsposter = $latest_array["postusername"]; 
$newsposterid = $result_thread_array["userid"]; 
$newsdate = date("D j M Y", $latest_array["dateline"]); 
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"]; 
$newscomments = $latest_array["replycount"]; 
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];

// split apart long URL strings
$newstext=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$newstext); 
$newstext=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$text); 

$newstext=eregi_replace("\\[url=\"([^\"]*)\"\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$newstext); 
$newstext=eregi_replace("\\[url=([^\"]*)\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$newstext); 
//special thank-you to Menno at vBulletin Community Forum for coming up with the above part!

if ($threadiconid==0) {
 $threadicon = "";
 }
else {
 $threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\">&nbsp;";
 }

if ($newscomments==1) {
 $commenttext = "reply ?";
 }
else {
 $commenttext = "replies ?";
 }

print("
			<table width=\"155\" cellpadding=\"2\">
				<tr>
					<td width=\"150\" bgcolor=\"#0066CC\" class=\"sidebar1\">
						<b>$threadicon$newstitle</b><br>
					</td>
				</tr>
				<tr>
					<td width=\"150\" class=\"sidebar1\">
						Posted in <a href=\"http://www.jjr512.com/bbs/forumdisplay.php?forumid=$threadforumid\" class=\"sidebar1\">$threadforum</a> by <a href=\"http://www.jjr512.com/bbs/member.php?action=mailform&userid=$newsposterid\" class=\"sidebar1\">$newsposter</a> on $newsdate:<br>
						\"$newstext...\"<br><a href=\"http://www.jjr512.com/bbs/showthread.php?threadid=$newsthreadid\" class=\"sidebar1\">$newscomments $commenttext</a><br><p>
					</td>
				</tr>
			</table>
"); 
} 

?>
Here is a link to a text file containing the above, in case some part gets messed up: http://www.jjr512.com/bbs/activetopics.txt

Please note that because I could never get the global.php file to properly include, I just ended up replacing the four variables at the top for server, username, PW, and db name with the actual values. (Of course, I replaced them back before posting it here for you! )
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 06:42 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.09846 seconds
  • Memory Usage 2,296KB
  • Queries Executed 25 (?)
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_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • 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