vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   pagination and drop down session (https://vborg.vbsupport.ru/showthread.php?t=319038)

Mickie D 06-11-2015 05:12 PM

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

cellarius 06-12-2015 04:28 AM

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.

Mickie D 06-12-2015 04:46 AM

Quote:

Originally Posted by cellarius (Post 2547650)
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
    
    
); 


cellarius 06-12-2015 05:58 AM

Glad you got it sorted (pun fully intended) ;)


All times are GMT. The time now is 03:23 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.00956 seconds
  • Memory Usage 1,745KB
  • 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_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete