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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2008, 12:56 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default thread list numbering

say i have a page with lists of threads that cross over pages

example at the moment i have got it showing

1
2
3
4
5
6
etc

and its 40 perpage

but once it reaches 40 and i change to the next page it starts from 1 again instead of

41
42
43
etc

can anyone help me with this problem
Reply With Quote
  #2  
Old 01-16-2008, 11:19 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Multiply the "per page" by the "page number - 1". Then add the result on to your increment counter or w/e you are using to count.
Reply With Quote
  #3  
Old 01-16-2008, 11:22 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

m8 can u give me the php to do this my counter has packed up its now showing -39 and -80

thx in advance :P
Reply With Quote
  #4  
Old 01-16-2008, 12:38 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well it depends on your script...
PHP Code:
// $perpage - stores number of items perpage make sure you use intval() on it somewhere
// $curpage - current page number make sure you use intval() on it somewhere
if($curpage != 0)
{
    
$startfrom $perpage * ($curpage 1);
}
else
{
    
$startfrom 1;

Something along those lines.
Reply With Quote
  #5  
Old 01-16-2008, 02:01 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

heres my code page nav works etc just need to get the counter working can i show me with the full code $count is the varible i will be using to add a number to the front of each thread.

thx in advance :P

PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''index'); // change this depending on your filename

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

);

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

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

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

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/functions_bigthree.php');

function 
timeDiff($timestamp,$detailed=false){
    
$now time();


    
$diff = ($action == 'away' $timestamp $now $now $timestamp);

    
# Set the periods of time
    
$periods = array("s""m""h""d""w");
    
$lengths = array(160360086400604800);

    
# Go from decades backwards to seconds
    
$i sizeof($lengths) - 1;         # Size of the lengths / periods in case you change them
    
$time "";                        # The string we will hold our times in
    
while($i >= 0) {
        if(
$diff $lengths[$i-1]) {        # if the difference is greater than the length we are checking... continue
            
$val floor($diff $lengths[$i-1]);    # 65 / 60 = 1.  That means one minute.  130 / 60 = 2. Two minutes.. etc
            
$time .= $val .""$periods[$i-1].($val '' ' ');  # The value, then the name associated, then add 's' if plural
            
$diff -= ($val $lengths[$i-1]);    # subtract the values we just used from the overall diff so we can find the rest of the information
            
if(!$detailed) { $i 0; }    # if detailed is turn off (default) only show the first set found, else show all information
        
}
        
$i--;
    }
   
    
# Basic error checking.
    
if($time == "") {
        return 
"Error-- Unable to calculate time.";
    } else {
        return 
$time.$action;
    }
}

// ###################################################################
// ######################## START MAIN SCRIPT ########################
// ###################################################################

$array "59,63,64,69,72";

    
// Default page variables
    
$perpage $vbulletin->input->clean_gpc('r''perpage'TYPE_UINT);
    
$pagenumber $vbulletin->input->clean_gpc('r''pagenumber'TYPE_UINT);
    
$sortfield $vbulletin->input->clean_gpc('r''sortfield'TYPE_STR);
    
$sortorder $vbulletin->input->clean_gpc('r''sortorder'TYPE_STR);

// set defaults and sensible values

if ($sortfield == '')
{
    
$sortfield 'age';
}
if (
$sortorder == '')
{
    
$sortorder 'desc';
}

$sortorder strtolower($sortorder);

    
// Count all log entries
    
$count $db->query_first("
        SELECT COUNT(*) AS `count`
        FROM " 
TABLE_PREFIX "thread AS thread
        WHERE thread.forumid IN(
$array)
    "
);

    
// Make sure all these variables are cool
    
sanitize_pageresults($count['count'], $pagenumber$perpage10040); 

    switch (
$sortfield)
    {
        case 
'username':
            
$sqlsort 'thread.postusername';
            break;
        case 
'subject':
            
$sqlsort 'thread.title';
            break;
        case 
'type':
            
$sqlsort 'thread.iconid';
            break;
        default:
            
$sqlsort 'thread.dateline';
            
$sortfield 'age';
    }

    if (
$sortorder != 'asc')
    {
        
$sortorder 'desc';
        
$oppositesort 'asc';
    }
    else
    { 
// $sortorder = 'ASC'
        
$oppositesort 'desc';
    }



    
$sorturl 'index.php?' $vbulletin->session->vars['sessionurl'] . '';


    eval(
'$sortarrow[' $sortfield '] = "' fetch_template('forumdisplay_sortarrow') . '";');

    
// Default lower and upper limit variables
    
$limitlower = ($pagenumber 1) * $perpage 1;
    
$limitupper $pagenumber $perpage;
    if (
$limitupper $count['count'])
    {
        
// Too many for upper limit
        
$limitupper $count['count'];
        if (
$limitlower $count['count'])
        {
            
// Too many for lower limit
            
$limitlower $count['count'] - $perpage;
        }
    }
    if (
$limitlower <= 0)
    {
        
// Can't have negative or null lower limit
        
$limitlower 1;
    } 

    
$threadarray $vbulletin->db->query_read("
        SELECT thread.*, icon.title AS icontitle, icon.iconpath AS iconpath, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid

        FROM " 
TABLE_PREFIX "thread AS thread 
        LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON(icon.iconid = thread.iconid)
        LEFT JOIN  " 
TABLE_PREFIX "user AS user ON (user.username = thread.postusername)
        WHERE 
$typequery
thread.forumid IN(
$array)
        ORDER BY 
$sqlsort $sortorder $secondarysortsql
        LIMIT " 
. ($limitlower 1) . ", $perpage ");
    
    while(
$thread $vbulletin->db->fetch_array($threadarray))
    {
        
$thread[musername] = fetch_musername($thread);  
        
        
$thread['lastpostdate'] = timeDiff($thread['dateline']);

    
// Finally construct the page nav
    
$pagenav construct_page_nav($pagenumber$perpage$count['count'], 'index.php?' $vbulletin->session->vars['sessionurl'] . '');  


if(
$count['count'] != 0)
{
    
$startfrom $perpage * ($count['count'] - 1);
}
else
{
    
$startfrom 1;


        

$images $db->query("
        SELECT img FROM " 
TABLE_PREFIX "post
        WHERE threadid = 
$thread[threadid]
    "
);
    while (
$image $db->fetch_array($images))
    {
        
$image_url $image['img'];
    }

        eval(
'$threadbits .= "' fetch_template('index_threadbit') . '";');        

    }

$navbits = array();
$navbits[$parent] = 'Thread Index';

$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('INDEX') . '");');

?>
Reply With Quote
  #6  
Old 01-18-2008, 09:14 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can no one help then i guess ?
Reply With Quote
  #7  
Old 01-18-2008, 11:44 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Place the part where you set $startfrom, outside the loop that displays the thread. Then increment the counter when your inside the while loop.
Reply With Quote
  #8  
Old 01-18-2008, 12:40 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i dont uner stand m8 can u show me with the code i posted ? thx in advance
Reply With Quote
  #9  
Old 01-18-2008, 01:21 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not going to code if for you...

PHP Code:
// Set up the counter with the code I posted in post #4
$threadnum $startfrom;
$db->query....
while(
$somevar $db->fetch_array(...
{
    
// Do your other code here
    // Use $threadnum in your template or where ever you want to use the counter
   
    // Increment the counter
    
$threadnum++;

Reply With Quote
  #10  
Old 01-18-2008, 03:03 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorted m8 but $startfrom = $limitlower - 1; to get the correct number :P

thx again :P
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 12:47 PM.


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.04649 seconds
  • Memory Usage 2,316KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete