![]() |
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! |
PHP Code:
|
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. |
You can place the code in one of the "_start" hooks. For example, for showthread.php, showthread_start.
|
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. |
|
Quote:
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:
http://www.mydomain.com/forums/forum...=9&e=2&b=2&g=4 Again, thank you for the help. |
Typing:
PHP Code:
|
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']}"> Code:
<a href="/forums/forumdisplay.php?f=2"> Code:
<a href="/forums/forumdisplay.php?f="> 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... |
In your plugin temporarily add
PHP Code:
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. |
Opserty...as you described, I got "int(2)" in the top LEFT of the page. (no need to view HTML)
So, the value is getting passed into the page successfully. This is good. Why can I not call that variable in the HTML tag below? Do I need to escape the variable name perhaps? HTML Code:
<a href="/forums/forumdisplay.php?f={$vbulletin->GPC['b']}"> HTML Code:
<a href="/forums/forumdisplay.php?f=2"> |
Ok that is good news. At least it is being passed correctly. (You can remove the var_... line if you haven't done so already).
In place of the var_... line add this: PHP Code:
|
The header template is eval in global.php so showthread_start is to late to insert variables into.
You can use to code after all your code in your plugin PHP Code:
PHP Code:
|
Oh, forgot about that :p Well spotted ;)
v0xb0x use the code you posted in post #7, but with the hook location global_start and combine it with the second piece of PHP code posted by MoT3rror. Then the code in post #8 should work, hopefully. :D |
Reading...
--------------- Added [DATE]1214861398[/DATE] at [TIME]1214861398[/TIME] --------------- Quote:
Here's the current evolution: 1. Plug-in's are enabled in Admin-CP 2. Created a new plugin called navTransport 3. Hook Location is now 'global_start' 4. Inserted this code: PHP Code:
HTML Code:
<a href="/forums/forumdisplay.php?f={$vbulletin->GPC['b']}"> HTML Code:
<a href="/forums/forumdisplay.php?f=2"> HTML Code:
<a href="/forums/forumdisplay.php?f="> http://www.mydomain.com/forums/forum...=9&e=2&b=2&g=4 So close here. Any other ideas? Is there some special 'escaping' I need to perform on the variable to expose it? Again, thank you _both_ for your foo. |
Use:
PHP Code:
|
HOLD THE PRESSES!
HOLD THE PRESSES! By withdrawing the code from the condition, the variable is being passed successfully! So, here's what we have in the plugin - location is 'global_start': PHP Code:
HTML Code:
<a href="/forums/forumdisplay.php?f={$vbulletin->GPC['e']}"> HTML Code:
<a href="/forums/forumdisplay.php?f=2"> Gents, I appreciate your time, patience and expertise. Please let me know how I can return the favor. --------------- Added [DATE]1214867069[/DATE] at [TIME]1214867069[/TIME] --------------- Follow Up! Is there an easy way for me to get these values that I pass into the vBulletin templates to persist for the life of the user's session? Is there a switch that we can call to maintain the values I pass in? |
ok, I am having trouble with this same thing.
I have: PHP Code:
later I have PHP Code:
PHP Code:
PHP Code:
this is irritating, because I can't figure out when the variable will be set and when it won't. For PHP Code:
|
Make sure you globalise $vbulletin if calling from inside a function.
|
This is a helpful bit, but I'm having one little issue with it.
On topics with multiple pages when I click to go to the next page, my varible gets lost... is there anyway to scope variables to retain them within a thread? IE when you visit ....showthread.php?t=3&myvar=2 then when I click on page 2 of this thread, i want it to go to showthread.php?t=3&page=2&myvar=2 Again, within the tread only... so I guess I need to somehow modify the thread pagination links |
You will need to pass variables between pages then. With any webbased script, each "page" is running in it's own environment so there are no variables inherit automatic from "previous pages".
|
All times are GMT. The time now is 07:02 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|