vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Passing variables in the query string (https://vborg.vbsupport.ru/showthread.php?t=183942)

v0xb0x 06-30-2008 02:50 AM

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!

Guest190829 06-30-2008 02:59 AM

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!

v0xb0x 06-30-2008 03:06 AM

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.

Dismounted 06-30-2008 05:58 AM

You can place the code in one of the "_start" hooks. For example, for showthread.php, showthread_start.

v0xb0x 06-30-2008 04:13 PM

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.

Opserty 06-30-2008 04:17 PM

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.

v0xb0x 06-30-2008 05:16 PM

Quote:

Originally Posted by Opserty (Post 1563173)
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.

Opserty 06-30-2008 05:38 PM

Typing:
PHP Code:

{$vbulletin->GPC['b']} 

Into your header template would probably do the trick.

v0xb0x 06-30-2008 06:14 PM

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...

Opserty 06-30-2008 06:46 PM

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.


All times are GMT. The time now is 02:44 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.01096 seconds
  • Memory Usage 1,749KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete