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 06-30-2008, 02:50 AM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Passing variables in the query string

Newb question.

I've been through the forums and haven't been able to find something in particular that answers my question. Thanks in advance for any comments.

Here's what I need to get done:

I have a non-vBulletin html page and I want to pass 3 variables from that page into a vBulletin page.

www.mydomain.com/forumdisplay.php?a=1&b=2&c=3

Integers like the above - no text.

When I get to the vBulletin page, how do I read the three variables to get the numbers 1,2,3?

Basic, I know. Please help.

Thanks!
Reply With Quote
  #2  
Old 06-30-2008, 02:59 AM
Guest190829
Guest
 
Posts: n/a
Default

PHP Code:

# Sanitize the variables, all of them are unsigned integers
$vbulletin->input->clean_array_gpc('r', array('a' => TYPE_UINT'b' => TYPE_UINT'c' => TYPE_UINT));

#After you call this function, the sanitized variables are stored in $vbulletin->GPC array

echo $vbulletin->GPC['a'] . $vbulletin->GPC['b'] . $vbulletin->GPC['c'];

# Prints '123'; 
Make sure you always sanitize your variables - I can't tell you how important that is!
Reply With Quote
  #3  
Old 06-30-2008, 03:06 AM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Danny, thanks for the quick response.

Where exactly do I place this PHP code?

In the template I want to read the query string in?

Again, many thanks for the help.

------------------------------------------

Edit!

Let me be more specific:

I want to pass values for forumid's into the vBulletin page from a non-vBulletin page.

I was planning on stuffing the query string with the following:

www.mydomain.com/forumdisplay.php?f=1&c=2

...where f=forumid and c=calendarid

That way I can populate variables inside the header template for custom navigation.

Again, I appreciate any help.
Reply With Quote
  #4  
Old 06-30-2008, 05:58 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can place the code in one of the "_start" hooks. For example, for showthread.php, showthread_start.
Reply With Quote
  #5  
Old 06-30-2008, 04:13 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hanson, thanks for your reply. I'm sorry though, I'm not following.

I just went through the /forums directory and was unable to locate any file that ended with _start.*

Where does the showthread_start. file reside?

Is this the easiest way of passing variables from outside vBulletin into a vBulletin page?

Again, thanks so much for the help.
Reply With Quote
  #6  
Old 06-30-2008, 04:17 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is no mention of "file" in Dismounted's post...

Create a Plugin with a Hook location as stated in Dismounted's post.

In answer to your second question, the answer is probably yes.
Reply With Quote
  #7  
Old 06-30-2008, 05:16 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
Create a Plugin with a Hook location as stated in Dismounted's post.
Ah, ok. Closer. Much Closer. Please get me over the last challenges...

Just completed the following:

1. Plug-in's are enabled.
2. Created a new plugin called navTransport
3. Hook Location is 'forumdisplay_start'
4. Inserted this code:
PHP Code:

# Sanitize the variables, all of them are unsigned integers
$vbulletin->input->clean_array_gpc('r', array('b' => TYPE_UINT'e' => TYPE_UINT'g' => TYPE_UINT)); 
Last question, how do I call the variables b, e and g from within the 'header' template now after I've passed them via the query string like this:

http://www.mydomain.com/forums/forum...=9&e=2&b=2&g=4

Again, thank you for the help.
Reply With Quote
  #8  
Old 06-30-2008, 05:38 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Typing:
PHP Code:
{$vbulletin->GPC['b']} 
Into your header template would probably do the trick.
Reply With Quote
  #9  
Old 06-30-2008, 06:14 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not working. I've got to be missing something.

I have the following HTML tag in the header:

HTML Code:
<a href="/forums/forumdisplay.php?f={$vbulletin->GPC['b']}">
This should evaluate as:

Code:
<a href="/forums/forumdisplay.php?f=2">
However, it is evaluating as:

Code:
<a href="/forums/forumdisplay.php?f=">
The query string for the page is:

http://www.mydomain.com/forums/forum...=9&e=2&b=2&g=4

Perhaps there is something else that needs to be done?

Thanks again for all assistance...
Reply With Quote
  #10  
Old 06-30-2008, 06:46 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In your plugin temporarily add
PHP Code:
var_dump($vbulletin->GPC['b']); 
at the bottom of the PHP Code. Run the script again and check the output. There should be something like NULL or int(2) at the top of the screen. (You might need to view the HTML source of the page, but it should be listed at the very top).

You may find the rest of the page ceases to function correctly just ignore that, you can remove the line once you've followed the instructions.

Post what you get outputted here.
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 04:45 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.04246 seconds
  • Memory Usage 2,269KB
  • 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
  • (2)bbcode_code
  • (1)bbcode_html
  • (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
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (9)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_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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete