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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2015, 05:12 PM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default pagination and drop down session

I have successfully setup pagination for my new modification, which gets the information from the database then limits the results to 10 items per page.

The only trouble is that I would now like to sort the items by different values, but I am not sure how sessions work in the respect do I need to add a column to the MySQL database or just setup a session variable?

This is my code:

PHP Code:
        $orderby $vbulletin->input->clean_gpc('p''orderby'TYPE_NOTRIM);

        if(isset(
$orderby) ){

            switch (
$orderby){
            case 
"1":    $order "file_fullsize";     /*$sel_full = "selected='selected'";*/    break;
            case 
"2":    $order "file_timestamp";    /*$sel_time = "selected='selected'";*/    break;
            case 
"3":    $order "file_name";        /*$sel_name = "selected='selected'";*/    break;
            default:    
$order "file_fullsize";    
            } 
        }
        
        
$dir '/temp/'.$vbulletin->userinfo['username'] . "/";
        
$dirsql $vbulletin->db->query_read("SELECT * FROM " TABLE_PREFIX "web WHERE file_userid = '$r1' ORDER BY $order DESC LIMIT $limitlower$perpage"); 
Code for the dropdown
PHP Code:
<form id="form1" name="form1" method="post" action="web.php">
<
select name="orderby">
  <
option value="1" name="file_fullsize">File Size</option>
  <
option value="2" name="file_timestamp">File Added</option>
  <
option value="3" name="file_name">File Name</option>
</
select>  

<
input type="submit" />
</
form
This works great for page one of the pagination but because the pagination changes pages it just defaults the switch on any other page

file_fullsize

I guess that i need to store the drop down orderby variable across the pagination?

Thank you for any help
Mick
Reply With Quote
  #2  
Old 06-12-2015, 04:28 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to add your sort value to the pagination url parameters, then retrieve it (using get, not post in the input cleaner).

Don't forget to set your dropdown to the chosen value.
Reply With Quote
2 благодарности(ей) от:
MarkFL, Mickie D
  #3  
Old 06-12-2015, 04:46 AM
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Posts: 430
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cellarius View Post
You need to add your sort value to the pagination url parameters, then retrieve it (using get, not post in the input cleaner).

Don't forget to set your dropdown to the chosen value.
Thank you very much for you help.

I used the guide on here to setup the pagination,


This code is used in the pagination, to be honest, I did not take much notice of it just that it worked... But is this where I need to append the GET of the orderby value?

PHP Code:

    $pagenav 
construct_page_nav(
        
$vbulletin->GPC['pagenumber'],
        
$perpage,
        
$file_pages['files_count'],
        
'web.php?' $vbulletin->session->vars['sessionurl'], // the pagenav-link
        
''// to pass a second portion or the pagenav-link, gets directly appended to above
        
''// to pass an anchor
        
''// SEO-Link for thread, forum, member... pages - make the pagenav-links seo'ed if you use the paginator on one of those
        
''// Array to pass linkinfo for SEO-Link-Method
        
''  // Array to pass additional Info for SEO-Link-Method
    
); 
Thank you again, much appreciated

Mick

--------------- Added [DATE]1434095288[/DATE] at [TIME]1434095288[/TIME] ---------------

Cellerus you are a Legend, it was so easy when you think about it!!!

For anyone looking for the same issue I did as said above changed everything to GET (not POST). then just added in the orderby into the pagination construct

PHP Code:

    $pagenav 
construct_page_nav(
        
$vbulletin->GPC['pagenumber'],
        
$perpage,
        
$file_pages['files_count'],
        
'webspace.php?' $vbulletin->session->vars['sessionurl'], 
        
'&orderby='.$orderby // THIS IS WHERE I ADDED THE FORM CALL
    
    
); 
Reply With Quote
Благодарность от:
MarkFL
  #4  
Old 06-12-2015, 05:58 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got it sorted (pun fully intended)
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 07:28 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.06553 seconds
  • Memory Usage 2,218KB
  • 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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (3)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete