![]() |
|
#1
|
|||
|
|||
|
I've been busy for a couple days now on my vacation for making this pagenav, like the "page 1 of 3" etc that you see in the forumdisplay.php top right and bottom right. I wanted it on vba, in the newsmodule, so all the news would be accessible from the portal. I'm on my way to code it, only for the bottom right, under the shown news.
It's difficult, and before this I didn't know anything of sql, so it's still got a couple bugs, but I'm putting it on the forum here, if someone else wants to assist me in getting rid of these bugs, and making the code better. Here's how to install this hack: Code:
add to your vba cmps_index.php page:
define('NEWS_FORUMID', 'NR');
where nr is the nr of the forum from which the news is displayed, ie 14 (from f=14)
in modules/news.php replace:
$newslimit = 'LIMIT ' . ($mod_options['portal_news_maxposts'] + $mod_options['portal_news_enablearchive']);
with:
$news_forumid=NEWS_FORUMID;
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads
FROM " . TABLE_PREFIX . "thread AS thread
WHERE forumid = $news_forumid
");
$totalthreads = $threadscount['threads'];
$ppnews=$mod_options['portal_news_maxposts'];echo "ppnews: ".$ppnews;
$nrofpages=ceil($totalthreads/$ppnews);echo "<br>nrofpages: ".$nrofpages;
if(ereg("^[0-9]+$", $_GET['page']) and $_GET['page']!=0)
$askedpage=$_GET['page'];
else
$askedpage=1;
if($askedpage>$nrofpages)
$askedpage=$nrofpages;
$limit1=($askedpage-1)*$ppnews;echo '<br>askedpage: '.$askedpage;
$limit2=$limit1+$ppnews;
$newslimit="LIMIT $limit1,$limit2";echo "<br>newslimit: ".$newslimit;
$pagenav=construct_page_nav($askedpage,$ppnews,$totalthreads,"?");
echo "<br>totalthreads: ".$totalthreads;
and replace:
ORDER BY " . iif($mod_options['portal_news_sticky'], 'sticky DESC,') . iif($mod_options['portal_news_orderby'] == 'postdateline', 'dateline', $mod_options['portal_news_orderby']) . " $mod_options[portal_news_direction]
with:
ORDER BY 4 $mod_options[portal_news_direction]
and replace:
ORDER BY " . iif($mod_options['portal_news_sticky'], 'sticky DESC, ') . 'thread.' . iif($mod_options['portal_news_orderby'] == 'postdateline', 'dateline', $mod_options['portal_news_orderby']) . " $mod_options[portal_news_direction]
with:
ORDER BY 4 $mod_options[portal_news_direction]
and replace:
while ($news = $db->fetch_array($getnews))
{
with:
$i=1;
//this goes till a news count of 10...
while ($news = $db->fetch_array($getnews)) {
if($i==10)$jak10=$news;
if($i==9)$jak9=$news;
if($i==8)$jak8=$news;
if($i==7)$jak7=$news;
if($i==6)$jak6=$news;
if($i==5)$jak5=$news;
if($i==4)$jak4=$news;
if($i==3)$jak3=$news;
if($i==2)$jak2=$news;
if($i==1)$jak1=$news;
$i++;}
$i--;
while($i>0) {
if($i==10)$news=$jak10;
if($i==9)$news=$jak9;
if($i==8)$news=$jak8;
if($i==7)$news=$jak7;
if($i==6)$news=$jak6;
if($i==5)$news=$jak5;
if($i==4)$news=$jak4;
if($i==3)$news=$jak3;
if($i==2)$news=$jak2;
if($i==1)$news=$jak1;
$i--;
then create a new template module called pagenav, with template to include, adv_portal_pagenav
set "Use Module Wrapper Template" to "no"
then create a new template with title: adv_portal_pagenav, with in the body only:
$pagenav
Include the pagenav module UNDER the news module on your vba page (if your news module is 20, put pagenav at 30).
that's it, I'll also include the complete news.php file for if it's too much of a hassle to manually change. Note that it still has a couple bugs. You'll see the pagenav thing under the newsitems, you can put the nr of newsitems at say 5 or 10, I disabled the newsarchive module. By the way I left in some echo statements for testing. news.php the problem I'm grappling with now is with the $newslimit, the news only shows like half the threads. And to show 10 newsitems I have to write say LIMIT 20 30 which is not how it should be. My brains are not liking this, they're overcooking. Last edited by mark737; 01-03-2008 at 06:37 PM. |
|
#2
|
|||
|
|||
|
Im going to pull this apart during the working week and have a look at it, thanks for getting the ball rolling.
|
|
#3
|
||||
|
||||
|
database error ???
Last edited by DarkFaCe; 06-04-2008 at 06:39 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with $pagenav on browselilnks.php and dropdown menus. | neverstop | Troubleshooting & Problems | 5 | 10-31-2007 07:56 PM |
| News Archive/Duplicate News Module Issue | Xil Ze | Troubleshooting & Problems | 5 | 09-01-2007 02:03 PM |
| Anyway to read more of the news posed within News module within VBadvanced | Chief | Troubleshooting & Problems | 2 | 09-26-2006 08:34 PM |
| Pagenav Broken | absolutepunknet | Troubleshooting & Problems | 2 | 09-14-2006 08:39 PM |
| Numbers (link to pages) of the previous news in news module | JWEB | "How Do I..." Questions | 3 | 08-20-2005 03:54 AM |