vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   [RELEASE v2.x] OPNews v1.0 << Not just another 'news' script. (https://vborg.vbsupport.ru/showthread.php?t=26562)

merk 08-26-2001 09:00 PM

Well, after finding 'PluhNews', i thought to myself, why not create something that uses templates, and the $DB_site class?

Well, after a bit of twiddling, i reduced the querys to just one, and Got it working, took a while tho D:

First off, youll need to create 2 templates.

newsbit:
Code:

Posted By <a href="$forumspath/member.php?s=&action=getinfo&userid=$newsarray[postuserid]"><b>$newsarray[postusername]</b></a> at  <i>$dateposted</i>
</center>

<blockquote></a>$cookedthread</blockquote><center><a href="$forumspath/showthread.php?s=&threadid=$newsarray[threadid]"><b>$newsarray[replycount]</b> $commenttext</a> Last comment was by <b>$newsarray[lastposter]</b></a></center>

<hr noshade height="1" width="60%">

This is just example code, basically the same as PluhNews' Code, i dont have time to make it a bit mroe spicey, but im sure you can work it out.

shownews:
Code:

Your Header Code Here

$newsbits

Your Footercode here.

And finally, create news.php in the forum root directory, and put this in it:
PHP Code:

<? 
error_reporting(7);
$templatesused='header,headinclude,phpheader,newsbit,shownews';
$loadbirthdays=1;
$loadmaxusers=1;

//Configuration Options
//What is the ID of your News forum?
$newsforums = 107;

//How many news items should be displayed?
$newsitems = 10;

//Path to your forums directory (leave out trailing slash)
$forumspath = "/forum";

require('./global.php');

$newsquery = "SELECT thread.*, post.*";
$newsquery .= " FROM thread,post";
$newsquery .= " WHERE post.threadid=thread.threadid";
$newsquery .= " AND thread.forumid=$newsforums";
$newsquery .= " GROUP BY thread.threadid";
$newsquery .= " ORDER BY thread.dateline DESC";

$news=$DB_site->query($newsquery);

while ($newsarray=$DB_site->fetch_array($news)) {

        $dateposted = vbdate("jS F Y, H:i",$newsarray[dateline]);

if ($newsarray[replycount]==1) {
    $commenttext = "Comment";
}
else {
    $commenttext = "Comments";
}

    $cookedthread=bbcodeparse2($newsarray[pagetext],"1","1","1","1");
    $test1 .= "test";
    eval("\$newsbits .= \"".gettemplate("newsbit")."\";");

}

eval("dooutput(\"".gettemplate("shownews")."\");");

?>

Thats basically it really!.

Im sure there are a few little errors in my coding, im a bit rusty with PHP :(

Next i plan on making a 'column' system(ie http://fortress.challenge-au.com) And actually, its for that site :)

<edit>
Im not sure if this supports multiple forums. Some feedback maybe?

Also- maybe there may be some point in using replacment variables in this, but hey, i couldnt be bothered ;)
</edit>

jasoncorn 08-27-2001 01:00 PM

Thank you! This is perfect. Installs in 1 minute and works well. Exactly what I needed. :)

JJR512 08-27-2001 04:56 PM

Can we see a demo site?

DjSao 08-27-2001 06:31 PM

very nice hack, it works perfectly

merk 08-27-2001 08:42 PM

Excuse the content of the actual posts..

(Nothing bad, but nothing thats really useful :)


http://www.opticpower.net/forum/news.php

JJR512 08-28-2001 05:14 AM

OK, how can I make it so the newest thread is at the top, rather than the bottom?

DjSao 08-28-2001 05:15 AM

Hey just wondering about one thing, i added the threads title to the newspage, but i'm wondering if its possible to make the title capital letters only, like some kind of line of code that replaces all letters in the title to capitals.

merk 08-28-2001 07:04 AM

Quote:

Originally posted by JJR512
OK, how can I make it so the newest thread is at the top, rather than the bottom?
I get this already-

However, i think i forgot to add a touch of code.

To change it, you need to modify the code block:
Code:

$newsquery = "SELECT thread.*, post.*";
$newsquery .= " FROM thread,post";
$newsquery .= " WHERE post.threadid=thread.threadid";
$newsquery .= " AND thread.forumid=107";
$newsquery .= " GROUP BY thread.threadid";

to

Code:

$newsquery = "SELECT thread.*, post.*";
$newsquery .= " FROM thread,post";
$newsquery .= " WHERE post.threadid=thread.threadid";
$newsquery .= " AND thread.forumid=107";
$newsquery .= " GROUP BY thread.threadid";
$newsquery .= " ORDER BY thread.dateline DESC";


merk 08-28-2001 07:07 AM

Quote:

Originally posted by DjSao
Hey just wondering about one thing, i added the threads title to the newspage, but i'm wondering if its possible to make the title capital letters only, like some kind of line of code that replaces all letters in the title to capitals.
In the While statment,

Add BEFORE (about line 41)
PHP Code:

eval("\$newsbits .= \"".gettemplate("newsbit")."\";"); 

PHP Code:

$uppercasenews strtoupper($newsarray[title]); 

Then, to reference the uppercase title, instead of using $newsarray[title] in the newsbit template, change it to $uppercasenews.

Btw, i havent tested this, but it should work in theory

DjSao 08-28-2001 08:26 AM

thanks, worked great.


All times are GMT. The time now is 01:25 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.01661 seconds
  • Memory Usage 1,746KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_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