Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 10-17-2014, 04:08 PM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Problem with pagination URL

Hello all,

Does anybody know what appears in the URL when one parameter is array? eg:
&genders=Array&roles=Array
is correct?

Actually it must be correct as the pagination works just fine (I mean navigating between the pages), but I can't get the values for another action that I want.

Testing the 1st page with:
Code:
if (is_array($genders))
{
	echo "1";
	print_r($genders);
}
I'm getting: 1Array ( [0] => 1 [1] => 2 ) which is correct. But moving to any other page I'm getting: 1Array ( ) . Empty array.

The most important parts of the code before are:
Code:
$vbulletin->input->clean_array_gpc('r', array(
'homeform' => TYPE_INT,
'genders' => TYPE_ARRAY_INT,
'roles' => TYPE_ARRAY_INT,
....
));
$genders = $vbulletin->GPC['genders'];
$roles = $vbulletin->GPC['roles'];
// Below I've the code for counting the amount of rows etc etc.
..........
// Storing the values to pass them as parameters
$postvalues .= "&genders=".$genders;
$postvalues .= "&roles=".$roles;
// Finally building the page navigation
$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'dating.php?' . $vbulletin->session->vars['sessionurl'] . 'do=searchresults'.$postvalues.'');
I also tried in postvalues:
Code:
$postvalues .= "&genders=".implode(',',$genders);
This changed the URL to &genders=1,2 but still can't get the values. Don't know if in this case I must use: TYPE_STR instead of TYPE_ARRAY_INT

Any idea is welcome

Thank you
Reply With Quote
  #2  
Old 10-17-2014, 05:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Since you are getting passed a single value (ie. initially it is genders=1 or genders=2, right?), then it is simply a string or integer at that point - it isn't an array that is getting passed via the URL.
Reply With Quote
  #3  
Old 10-17-2014, 06:13 PM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Since you are getting passed a single value (ie. initially it is genders=1 or genders=2, right?), then it is simply a string or integer at that point - it isn't an array that is getting passed via the URL.
First of all thank you for your prompt attention. You're always here to help people. Really appreciated.

No, I'm passimg array of values from the initial form to genders[]. The first page works just fine. I'm using these array values to preselect the form that exists in the searchresults page.

The problem starts to appear when I'm navigating to any other page using the pagination (always on the same php file/page). The navigation works, but I'm loosing the values of the variables.

Maybe the solution can be childish. Is that $postvalues at the end of:
Code:
$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'dating.php?' . $vbulletin->session->vars['sessionurl'] . 'do=searchresults'.$postvalues.'');
something needing for constructing the pagination, or not? If not then I believe that I can find a solution.

Thank you again
Reply With Quote
  #4  
Old 10-17-2014, 06:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're passing an actual array? What does this URL look like initially - &genders=1,2&roles=1,2 ?
Reply With Quote
  #5  
Old 10-17-2014, 06:40 PM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You're passing an actual array? What does this URL look like initially - &genders=1,2&roles=1,2 ?
Yes, the URL appears like that if I use the implode function like:
Code:
$postvalues .= "&genders=".implode(',',$genders);
$postvalues .= "&roles=".implode(',',$roles);
If I use:
Code:
$postvalues .= "&genders=".$genders;
$postvalues .= "&roles=".$roles;
then the URL looks like: &gender=Array&roles=Array
Reply With Quote
  #6  
Old 10-17-2014, 08:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I notice you aren't separating the post variables with "&" which would need to be done after do=searchresults (the session variable has one at the end). So, you need to fix that. But, I'd also suggest looking at the construct_page_nav function (in functions.php) because I'm not totally sure if it is set up to handle and array being passed.
Reply With Quote
  #7  
Old 10-18-2014, 06:24 AM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Finally I was able to solve the problem and I'm posting the solution here just in case someone else finds the same problem when passing arrays in URL. The trick is to use serialize/unserialize.

So in the passing to the URL you use:
PHP Code:
$url urlencode(serialize($array)) 
and to restore the variable you use
PHP Code:
$var unserialize(urldecode($_GET['array'])) 
Thank you very much Lynne.
Reply With Quote
Благодарность от:
Lynne
  #8  
Old 10-18-2014, 04:55 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm glad you figured it out and thanks for posting the solution.
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:37 AM.


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.13913 seconds
  • Memory Usage 2,244KB
  • Queries Executed 13 (?)
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
  • (6)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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