PDA

View Full Version : vBadvanced CMPS - News Digest Module 1.02


Michael Morris
10-02-2004, 10:00 PM
This header message last editted October 10th.

News Digest for vBadvanced CMPS
vers. 1.0.2

This hack allows your vBadvanced hompage to display news in a digest format. Instead of having each article appear in a box, it will appear as an item in a bulleted list. These lists are sorted by date and then by category. If you're site has more than a couple of news items per day you should find this hack useful, especially if those news items are particularly small by themselves (only a line or two of text).

Live examples:
http://www.enworld.org/forums/index.php (starting below the ad for Dundjinni).

This hack requires that you have vBadvanced CMPS of course. Image support for the categories (as seen on the enworld site) can be accomplished by installing BeerMonster's banner images on forumhome hack. If you don't want to install this other hack, or if you're boards has a different hack that associates images with forums, you'll need to modify the provided newsdigest.php file.

BeerMonster's hack is found here...
https://vborg.vbsupport.ru/showthread.php?t=63994

During the installation of this hack you will create 3 templates. This hack requires no file modifications in and of itself, but some supplemental hacks do require such modifications, and they'll be dealt with in detail shortly. First, the primary hack:

Step 1: Prepare the newsdigest.php file.
Download the attached file and put it in [yourforum]/modules/

Step 1A:
If you don't want to have any forum images for your categories, or don't wish to install the forum banners hack above then open the newsdigest.php file and search for the following code.

Find:
SELECT thread.threadid, postusername, postuserid, thread.dateline AS postdateline, thread.forumid, forum.title as title, forum.fhbanner as icon, post.postid, pagetext, allowsmilie

Replace With:
SELECT thread.threadid, postusername, postuserid, thread.dateline AS postdateline, thread.forumid, forum.title as title, post.postid, pagetext, allowsmilie

Advanced Users Note: the only difference between these two blocks is the 2nd lacks the "forum.fhbanner as icon," entry. If you have already installed a hack that creates forum images for use with categories you can change this line to refer to the column you've set. For instance, on enworld the line is "forum.icon as icon,"

Step 2: Create the Templates
Create a new template called adv_portal_newsdigest_date and insert the following into it:


<if condition="$prevdate"><br /><hr></if>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" valign="top" class="tborder">
<table align="center" border="1" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" width="100%">
<tr>
<td align="center" valign="top" class="tcat">
$datelongform
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>


Create a new template called adv_portal_newsdigest_category and insert the following into it.


<b>$news[title]</b><if condition="$news['icon']"><img src="./images/forumicons/$news[icon]" align="right" height="60" weight="60"></if>


If you don't want category images insert this code instead:


<b>$news[title]</b>


Create a new template called adv_portal_newsdigest_item and insert the following into it:


<div align="justify">$news[message] - scoop submitted by $news[postusername]</div>


Step 3: Set up your News Forums
Go to your forum manager and create one news forum for each news category you desire to have on your news page. Also choose their display order at this step by modifying the display orders of the forums themselves. Note their forum #'s

Step 4: Prepare the News Page
Open your vBadvanced CMPS control panel and select "Add Module"

Module Title: News Digest
File to Include: newsdigest.php

Templates to Include: adv_portal_newsdigest_date, adv_portal_newsdigest_category, adv_portal_newsdigest_item

Step 5: Activate the Module
Go to your page settings and turn the original news module off (It's redundant). Enter the forum #'s of each forum you want in any order (the display order of the categories is the same as the forums. Turn the newsdigest module on.

---------------------------------------------------------

FINISHED.

Version History
Version 1.0.0 had several little glitches due to me rushing it out the door in my excitement from creating my first big hack. I'll demonstrate a bit more patience in the future.

Version 1.0.1 (and prior) has a serious month wrap bug.

Version 1.0.2 is current.

If you like this hack please click install - thx.

---------------------------------------------------------

Supplemental Hack: Bump and Debump News
The date of the news is important with this hack. If you find an item displaying on the wrong day then you can use the following tools to scoot it around. Note - this "supplemental" hack is almost exactly like Rigel Kentaurus' "Bump Thread and Make Thread Older" hack, so I'm not going to take any credit for originality. Here is the modified version of his hack for bumping news items around for the digester.


Code Modifications: 2 in 1 file
Template Modifications: 2 in 1 template
New phrases: 4

################################################## #################
# Code modifications in file "postings.php"
################################################## #################

-------------------------------------------------------------------
search for this code:
-------------------------------------------------------------------

case 'removeredirect':

-------------------------------------------------------------------
change it to:
-------------------------------------------------------------------

case 'removeredirect':

// Hack: bump and debump
case 'bumpnews':
case 'debumpnews':



-------------------------------------------------------------------
search for this code:
-------------------------------------------------------------------



// ############################### start do open / close thread ###############################



-------------------------------------------------------------------
change it to:
-------------------------------------------------------------------



// ############################### start news bump and de-bump ###########################
if ($_REQUEST['do'] == 'bumpnews')
{
// only mods with the correct permissions should be able to access this
if (!can_moderate($threadinfo['forumid'], 'caneditthreads'))
{
print_no_permission();
}

// Bump
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET dateline=".TIMENOW." WHERE

threadid='".$threadinfo['threadid']."'");

$url = "forumdisplay.php?$session[sessionurl]f=$threadinfo[forumid]";
eval(print_standard_redirect('redirect_bumpnews')) ;
}

if ($_REQUEST['do'] == 'debumpnews')
{
// only mods with the correct permissions should be able to access this
if (!can_moderate($threadinfo['forumid'], 'caneditthreads'))
{
print_no_permission();
}

// De-Bump
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET dateline=dateline-86400 WHERE

threadid='".$threadinfo['threadid']."'");

$url = "forumdisplay.php?$session[sessionurl]f=$threadinfo[forumid]";
eval(print_standard_redirect('redirect_debumpnews' ));
}



################################################## #################
# Template modifications in SHOWTHREAD
################################################## #################

-------------------------------------------------------------------
search for this:
-------------------------------------------------------------------

<option value="removeredirect">$vbphrase[remove_redirects]</option>

-------------------------------------------------------------------
change it to:
-------------------------------------------------------------------

<option value="removeredirect">$vbphrase[remove_redirects]</option>
<option value="bumpnews">$vbphrase[bumpnews]</option>
<option value="debumpnews">$vbphrase[debumpnews]</option>


-------------------------------------------------------------------
search for this:
-------------------------------------------------------------------

<div><label for="ao_rrd"><input type="radio" name="do" id="ao_rrd" value="removeredirect" />$vbphrase[remove_redirects]</label></div>

-------------------------------------------------------------------
change it to:
-------------------------------------------------------------------

<div><label for="ao_rrd"><input type="radio" name="do" id="ao_rrd" value="removeredirect" />$vbphrase[remove_redirects]</label></div>
<div><label for="ao_bump"><input type="radio" name="do" id="ao_bump" value="bumpnews" />$vbphrase[bumpnews]</label></div>
<div><label for="ao_dbump"><input type="radio" name="do" id="ao_dbump" value="debumpnews" />$vbphrase[debumpnews]</label></div>


################################################## #################
# New phrases
################################################## #################

Add these four phrases in the admin control panel (Phrase Manager -> Add new Phrase)

Type: Show thread
Name: bumpnews
Text: Bump News

Type: Show thread
Name: debumpnews
Text: Make News older

Type: Front-End Redirect Messages
Name: bumpnews
Text: The News item is now set to today

Type: Front-End Redirect Messages
Name: debumpnews
Text: The News Item is now one day older

nexialys
10-02-2004, 11:58 PM
a onsite example would be cool.. ;)

Michael Morris
10-03-2004, 12:39 AM
Certainly.

http://www.enworld.org/forums/news.php

KW802
10-03-2004, 01:54 AM
The goal output is

http://www.enworld.org/forums/news.phpAh, now I understand what you're describing! In this case each "category" is really a forum, right?

Michael Morris
10-03-2004, 02:21 AM
Ah, now I understand what you're describing! In this case each "category" is really a forum, right?

Yuppers.

Michael Morris
10-03-2004, 01:52 PM
Out of beta now - it's been running 12 hours on my site and I've tested everything I think. I will pitch in if it causes problems.

My apologies for getting all giddy yesterday and rushing this out a wee bit early - this is my first major hack (though it's nothing compared to what I've planned).

robert_2004
10-03-2004, 02:22 PM
sweet dude :D:D:D
honestly - i always wanted this sort of setup for my old board (running phpbb :S )
this will allow the 5 or so news posters to put up news throughout the day and not continue to make new boxes, that clutter.
it was hard to understand what you meant at first, until i saw your example.
i'll keep you posted after some testing in a few days....

Michael Morris
10-03-2004, 10:31 PM
Found a display bug. I was using vbdate (); out of habit, but apparently that causes problems for any visitors who aren't on the same time zone as the server. Corrected by simply changing the newsdigest.php file - no changes to the install instructions or templates necessary.

Michael Morris
10-10-2004, 07:14 PM
This has been working a week now without any errors on my setup. Anyone have any ideas for improvements?

LPH2004
10-10-2004, 07:15 PM
This is gorgeous but how do I only get 2 days worth ... and not a whole HUGE string of days ... ?

I'm installing it on www.whatisnew.com

Michael Morris
10-10-2004, 07:26 PM
This is gorgeous but how do I only get 2 days worth ... and not a whole HUGE string of days ... ?

I'm installing it on www.whatisnew.com

The last part of the newsdigest.php file is the looks like this.

if ($vba_options['portal_news_forumid'])
{
$timespan = 'thread.dateline>UNIX_TIMESTAMP(CURDATE())';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-1)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-1) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-2)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-2) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-3)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-3) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-4)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-4) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-5)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-5) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-6)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-6) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-7)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-7) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-8)';
construct_newsdays();
}

The first line checks for any news posts made prior to the current date in case there's a glitch in the timestamp of the news item that puts it in the future it will still display. Each line that follows is one day. So, simply trim it down to the number of desired iterations. Two days would read...

if ($vba_options['portal_news_forumid'])
{
$timespan = 'thread.dateline>UNIX_TIMESTAMP(CURDATE())';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-1)';
construct_newsdays();
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-1) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-2)';
construct_newsdays();
}

I've tried a couple of times now to get this to work as a while loop but so far nothing gets displayed when I try it that way :(

LPH2004
10-10-2004, 07:42 PM
Thank you for the very fast response !

Now, it is starting to take shape by showing just 2 days.

However, it is showing up to 18 stories from the same category. I've looked where to change this to just up to 5 but I'm not sure. The story length cut down to 100 causes some of the stories to have all of the text linked/underlined. I've set it to 200 and stories are all red past a certain point.

Any ideas?

Michael Morris
10-10-2004, 08:06 PM
Thank you for the very fast response !

Now, it is starting to take shape by showing just 2 days.

However, it is showing up to 18 stories from the same category. I've looked where to change this to just up to 5 but I'm not sure. The story length cut down to 100 causes some of the stories to have all of the text linked/underlined. I've set it to 200 and stories are all red past a certain point.

Any ideas?

The line limiter is rather dumb, and it won't close tags. What do you want the limit on stories within a category to be?

LPH2004
10-10-2004, 08:24 PM
The line limiter is rather dumb, and it won't close tags. What do you want the limit on stories within a category to be?

Well, I decided to create Frontpage news forums for the major categories and then will make sure they do not exceed 500. They'll say something like "discuss this here" kinda posts.

I've updated the front of www.whatisnew.com now and am adding more of these "news" forums for each category.

Michael Morris
10-10-2004, 08:29 PM
Well, I decided to create Frontpage news forums for the major categories and then will make sure they do not exceed 500. They'll say something like "discuss this here" kinda posts.

I've updated the front of www.whatisnew.com now and am adding more of these "news" forums for each category.

Ok. Well, have fun with it and let me know if anything major crops up. I'm going to be working primarily on a Reviews database extention for vbulletin that allows users to post book reviews and look up product and product line information by publisher -though I'll try to keep if flexiable enough for any kind of reviews application. Part of that hack is translating a home-made program someone else wrote into a format vbulletin can deal with :\

Signing off now, and have a good day.

Jaxx
10-28-2004, 06:08 AM
Thanks a bunch.

I very pleased with it, you did a great job on it.

Is there any chance of getting some type of mod that would count the replies to a news article and put (# comments) next to it?

*edit*
Now that brings up, how would you moderate the new thread, but not the replies?

Michael Morris
10-28-2004, 07:12 AM
I think you can set up a forum so that only new threads are moderated and not new posts without performing any hacks.

Anyway, ENWorld runs an archive of news items by using vbulletin's syndicator - it shows the 20 most recent news items for each topic. To add one to go with this system create a new page, turn all modules off on that page and point it's custom content at a new template (I used adv_portal_headlines)

The content for us is...


<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="tborder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="tcat" align="center">Headline Summary Page</td></tr>
</table></td></tr></table>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="tborder">
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Site News</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=162&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Software</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=179&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Community</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=178&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
</td></tr></table></td>
<td width="34%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="tborder">
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Official WotC</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=164&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Books &amp; Novels</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=180&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Other</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=181&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
</td></tr></table></td>
<td width="33%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="tborder">
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">D20/OGL</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=163&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">PDF/e-publishing</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=111&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td align="center" class="thead">Sci-Fi/Fantasy</td></tr>
<script type="text/javascript" src="http://www.enworld.org/forums/external.php?forumids=110&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 45)
{ threads[i].title = threads[i].title.substring(0, 45) + '...'; }
document.writeln("<tr><td class=\"alt2\"><a href=\"http://www.enworld.org/forums/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a></td></tr>");
}
//-->
</script>
</table>
</td></tr></table></td>
</tr>
</table>
<br />
<div align="center"><a href="http://www.enworld.org/forums/news.php?page=syndicate">Click here
to syndicate these headlines</a>.</div>
<br />

Note that there's really not that much fancy going on here if you know HTML. The javascript uses the syndicator to fetch the headlines, and I carefully inserted the classes I wanted into each table row and header to get their colors to display right.

For this to work on your page you have to go to vboptions >> syndication and turn it on, choosing XML syndication. At that point a link will appear in each forum "Syndicate this page" Follow this instructions that appear.

If you need any help just yell.

Michael Morris
10-28-2004, 07:34 AM
Thanks a bunch.

I very pleased with it, you did a great job on it.

Is there any chance of getting some type of mod that would count the replies to a news article and put (# comments) next to it?


Easy enough. Open the provided newsdigest.php file. Find this code (It's almost at the start):


SELECT thread.threadid,

IMMEDIATELY AFTER INSERT

replycount,


The query should read like this after you're done


SELECT thread.threadid, replycount, postusername, postuserid,


and so on.

Doing that captures the reply count. You can now slip it into the news item by putting $news[replycount] into the template. For example, change the adv_portal_newsdigest_item template to:

<div align="justify">$news[message] - submitted by $news[postusername]. <a href="showthread.php?t=$news[threadid]">Comments: $news[replycount]</a></div>

Jaxx
10-28-2004, 07:43 AM
Thanks a bunch. :)

I ran across this though after doing the above. Sorry to be a bother, still relatively new to php.


Database error in vBulletin 3.0.3:

Invalid SQL:
SELECT thread.threadid, replycount, postusername, postuserid, thread.dateline AS postdateline,
thread.forumid, forum.title as title, forum.fhbanner as icon, post.postid, pagetext, allowsmilie
FROM thread AS thread
LEFT JOIN post AS post ON (post.postid = thread.firstpostid)
LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
LEFT JOIN deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
WHERE thread.dateline>UNIX_TIMESTAMP(CURDATE()) AND thread.forumid IN(45,46,42,43,44)
AND thread.visible = 1 AND thread.open != 10 AND deletionlog.primaryid IS NULL
GROUP BY post.postid
ORDER BY forum.displayorder
mysql error: Column: 'replycount' in field list is ambiguous

mysql error number: 1052

Date: Thursday 28th of October 2004 04:52:27 AM
Script: http://www.ahazi.org/forums/showthread.php?p=53981
Referer: http://www.ahazi.org/forums/editpost.php?do=editpost&p=53981

Michael Morris
10-28-2004, 07:56 AM
No problem :)

Michael Morris
10-28-2004, 08:35 AM
Hmm.. Try thread.replycount instead of just replycount

EDIT: That will work, though you'll need to make it alias to something else so that you can read the resultant variable.

Try thread.replycount AS comments

Then in the template the variable will be $news[comments]

EDIT2: To clarify the query will read as follows when you're done.

SELECT thread.threadid, thread.replycount AS comments, postusername, postuserid,

...and so on...

Jaxx
10-28-2004, 08:48 AM
Yuppers. That work.

And i'm just about done with the other part now too. Just need to finish linking it somewhere. :)


Edit 1:

Ok, found the syndication needed to be turned on was the external javascript. I wasn't getting anythign with the xml on.

http://ahazi.org/index.php?page=pastnews <--- But link at bottom is not working and i'm not seeing the link you talked about showing up either in the forums.

Michael Morris
10-28-2004, 09:23 AM
Oops, sorry.

We've got so many hacks running around on EN World it's hard to remember what the default features are..

The external javascript is kicked out by the hack in this thread

https://vborg.vbsupport.ru/showthread.php?t=59776

If you want to encourage people to syndicate your news I'd recommend it.

Michael Morris
11-01-2004, 01:38 PM
Just when you think everything's fine the file goes haywire when the month wraps over. New version uploaded. This one doesn't rely on the MySQL Unix Timestamp function but instead uses strtotime(); to find the UNIX timestamp for the start of each of the last 8 days (including today).

WAR
11-01-2004, 02:15 PM
Just when you think everything's fine the file goes haywire when the month wraps over. New version uploaded. This one doesn't rely on the MySQL Unix Timestamp function but instead uses strtotime(); to find the UNIX timestamp for the start of each of the last 8 days (including today).
How difficult would it be to turn this into a weekly news digest?

I tried this:

$timespan = strtotime('12:00 AM 2 weeks ago');
construct_newsdays();


And also changed the new query to:

WHERE thread.dateline>$timespan AND thread.forumid IN($vba_options[portal_news_forumid])
AND thread.visible = 1 AND thread.open != 10 $notdeleted


But it doesn't work it is still showing digests from yesterday and today (I installed it yesterday)
**It also seems to be showing them in the wrong order (yesterday's first followed by today's underneath***

I would like it to only display one digest at a time, updated daily, which includes all news posts from the last X number of days (instead of one digest a day displaying just items from that day) is that easily possible?

Michael Morris
11-01-2004, 02:40 PM
I would like it to only display one digest at a time, updated daily, which includes all news posts from the last X number of days (instead of one digest a day displaying just items from that day) is that easily possible?

Not until I rework the code. What I need to do to figure out how to load all the posts in the specified timespan into a single array that the code can then manipulate. The flowchart would be

1. Get the range of days (possibly using $_REQUEST or $_POST so that users can look stuff up).

2. Use strtotime() to convert the range to Unix timestamps.

3. Run the query, putting the posts into an array sorted by time.

4. Divide the array up by days within the range.

5. Further divide by categories

6. Assemble it.

Doing it this way would save a LOT of queries.

Michael Morris
11-01-2004, 02:42 PM
BTW, to be honest, this should be a default feature of vba_cmps IMO

Jaxx
11-01-2004, 10:22 PM
Great Michael! It worked.

I just had to change my forum.icon to forum.fhbanner. That was different from the pervious version also. :)

WAR
11-17-2004, 09:29 PM
BTW, to be honest, this should be a default feature of vba_cmps IMO
Were you planning on reworking this? Or should I start trying to slog my way through it?

That isn't intended to sound demanding at all, merely inquisitive.

KTBleeding
11-17-2004, 09:59 PM
Hmm. Is there an easy way to have it just display the title of the thread in the news forum and have that title link to the article?

Michael Morris
12-15-2004, 01:52 AM
I'll do some reworking after I finish a server upgrade for EN World.

Michael Morris
12-15-2004, 01:54 AM
Hmm. Is there an easy way to have it just display the title of the thread in the news forum and have that title link to the article?

Off the top of my head you'd have to add the news thread's query, then use that. When I can find the time I'll look this up.

acrimony
12-16-2004, 09:12 AM
I have been heavily modifying your code to fit my site (this is a fantastic script by the way) and I have run into a wall. I have split up my news posts into their respected category forums, but there is one annoying problem. The main page does not sort the news by time posted. Instead it is done (I believe, could be mistaken) by which forum it searches through first. How would I go about changing this so it is sorted by time posted? Again, fantastic hack!

Michael Morris
01-07-2005, 07:03 AM
It's been awhile since I've looked at this hack, so I'm not sure how to dodge that problem. I'm currently enrolled in an SQL course at ITT Tech, and once I finish it I should be better equipped to deal with this functional but still somewhat glitchy hack. This is what I have in mind for the next version.


The hack overall will become a display mode for news.php and exist in the same code. I intend to retain most if not all of Brian's original functionality for the news module. Basically you'll see one new line on your vbacmps config: Display as Digest? *Yes *No; with the default being no.
I'm now aware some of the ugliness in the code is due to the fact you can't nest while loops - so I'm gonna have to put a stop to that.
The number of days will still default at 7, but modifying it will be possible from the admincp
Users will be able to submit a scan range to the page in two ways determined by the admin. Method one is to allow them to choose weeks (i.e. Week starting Monday, January 3rd). The week starting will refer back to the user setting for start of the week in the case. Or the admin may simply set a day range, but be careful with that in case some yahoo decides to, say, search all news items between a couple of days that are months apart (which would set up a highly intensive query on the server). Obviously, a max time differential would be needed, now that I think about it (14 days sounds good to me).


Any other suggested features would be welcome.

Polo
03-14-2005, 02:48 PM
I really wanted to see this mod into action :ermm: anyone has a live link? this is what i'm getting in the link from the first post:

404 - File Not Found Error

RaZor Edge
03-18-2005, 02:21 PM
I really wanted to see this mod into action :ermm: anyone has a live link? this is what i'm getting in the link from the first post:

I have modify this mod a little bit, but here's my link:

http://lutte.fnnation.com/nouvelles.php

You can see the real mod in action with this link:
http://www.enworld.org/index.php

Michael Morris
03-18-2005, 02:26 PM
I really wanted to see this mod into action :ermm: anyone has a live link? this is what i'm getting in the link from the first post:

Sorry bout that - moved the furniture at EN World

The link above's corrected, but it is now at simply http://www.enworld.org

GiJoe
04-19-2005, 12:38 AM
I really would like to use this... But I'd like to keep some of the functionality of the original news posting for vBA. Namely being able to reply to the news posts and being able to "Read More" ... Any quick fix for this?

Jaxx
04-28-2005, 09:16 AM
GiJoe,

Take a look at my site: http://www.ahazi.org

It has the comments which was added in from the discussion on the 2nd page of this thread.

Is that basically what you mean?

DavidN
05-07-2005, 10:00 PM
This has been installed on my website :)

GiJoe
05-30-2005, 12:37 PM
GiJoe,

Take a look at my site: http://www.ahazi.org

It has the comments which was added in from the discussion on the 2nd page of this thread.

Is that basically what you mean?

Yep... Got it to work a little while ago thank you! :D http://wolfgaming.net

PING1434a
06-27-2005, 07:24 AM
Ok, i tried to install this on a 3.0.7, no luck, the instructions on steps 4 and 5 dosn't apply. Anyone had any lucky on their 3.0.7? Perhaps someone can share the info?

ragintajin
07-31-2005, 06:32 PM
This is exactly what I need...any chance you'll update it for vb 3.5??

Marris
08-08-2005, 03:51 AM
Thanks a lot for this mod. It was just what I was looking for.

I just wanted to add simple date breaks into the existing news, so I just used a snippet of the code to replace a line in news.php (CMPS v2.x):

in news.php replace:

eval('$newsbits .= "' . fetch_template('adv_portal_newsbits') . '";');

with:

//datemod 1 of 2 start

$dayposted = vbdate('njy', $news['postdateline']);

//Display The Current News Day
if ($dategroup != $dayposted)
{
$datelongform = vbdate('l, F jS, Y', $news['postdateline']);
$dategroup = vbdate('njy', $news['postdateline']);
$prevdate = true;
eval('$newsbits .= "' . fetch_template('adv_portal_newsdigest_date') . fetch_template('adv_portal_newsbits') . '";');
}else{
//datemod 1 of 2 end

eval('$newsbits .= "' . fetch_template('adv_portal_newsbits') . '";');

//datemod 2 of 2 start
}
//datemod 2 of 2 end

And in this case, you need to enclose the contents of adv_portal_newsdigest_date in <tr><td></td></tr> tags.

Also, note this only works if you have your News module option "Separate News Posts" set to "No", but it should be easy to figure out the code to change in news.php for this to work for the other mode.

All this does is divide up your normal News posts with a date bar. It doesn't have any of the extra functions of the full mod.

In using this with vB 3.0.8 and CMPS 2, I noticed I had to change the use of date() to vbdate() or else I would get discrepancies between the post dates and current time zone setting.

regina64
01-11-2007, 03:10 PM
I look forward to using your module.

I am currently running vb 3.6.4 and vBadvanced CMPS 2.2.1 and I would like to use the news digest module on it. Will this run on my version or do I need to wait for an update?

Had to ask before I tried to install.

Michael Morris
01-11-2007, 03:31 PM
I've decided to move to Joomla for content management so I won't be upgrading this for vba CMPS 2. If anyone wishes to do so they have my permission to post the code here.

KW802
01-11-2007, 03:43 PM
I've decided to move to Joomla for content management so I won't be upgrading this for vba CMPS 2. If anyone wishes to do so they have my permission to post the code here.Michael, with your OK I wouldn't mind taking this one over. I had almost forgotten about this thread until it got bumped and I realized I could use this on one of my sites. I need to go over the code a bit (since with CMPS 2.x you can just easily copy a module and then make edits to the copy) but it should be doable.

Michael Morris
01-11-2007, 03:49 PM
Michael, with your OK I wouldn't mind taking this one over. I had almost forgotten about this thread until it got bumped and I realized I could use this on one of my sites. I need to go over the code a bit (since with CMPS 2.x you can just easily copy a module and then make edits to the copy) but it should be doable.
Go right ahead - code's yours.

regina64
01-11-2007, 03:54 PM
Michael, sorry to see you go to Joomla. I was really looking forward to trying out your module.

I hope KW802 can figure it out. It looks like exactly what I need (organizing my front end by category)

Can you tell me if this site is using your module? I have been trying to figure it out for days on how they are displaying their categories on the homepage, but yet I don't see them in the forum (the categories):

http://www.gotapex.com/

see where it says:
Posted on Thursday January 11th, 2007 by Lights in the "Computers" category

Also, is this mod similar to yours?

Thread Category / Prefix Hack
https://vborg.vbsupport.ru/showthread.php?t=61494

KW802
01-11-2007, 04:02 PM
Go right ahead - code's yours.Thanks. :cool:

I hope KW802 can figure it out. It looks like exactly what I need (organizing my front end by category)It might be a day or so before I have a chance to work on it but I'll post whatever I come up with.

regina64
01-11-2007, 05:22 PM
Thank KW802,

I look forward to trying it out when you get done.