Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 06-30-2008, 07:02 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']}">
Again, this should evaluate as:

HTML Code:
<a href="/forums/forumdisplay.php?f=2">
PERSONAL NOTE: Many thanks for your time and expertise. Please let me know how I can repay the favor.
Reply With Quote
  #12  
Old 06-30-2008, 07:47 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
$specialvar_b =& $vbulletin->GPC['b']; 
Type $specialvar_b into your template, instead.
Reply With Quote
  #13  
Old 06-30-2008, 07:53 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
eval('$header = "' fetch_template('header') . '";'); 
or use global_start and use a if condition like this
PHP Code:
if(THIS_SCRIPT 'showthread')
{
//your code

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

Oh, forgot about that 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.
Reply With Quote
  #15  
Old 06-30-2008, 08:06 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reading...

--------------- Added [DATE]1214861398[/DATE] at [TIME]1214861398[/TIME] ---------------

Quote:
Originally Posted by Opserty View Post
...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.
No joy. This does NOT pass the variable into the HTML tag.

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:
if(THIS_SCRIPT 'showthread')
{
# 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));

I have the following HTML tag in the header template

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

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

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

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.
Reply With Quote
  #16  
Old 06-30-2008, 08:44 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use:
PHP Code:
if(THIS_SCRIPT == 'forumdisplay')
{
# 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));

Reply With Quote
  #17  
Old 06-30-2008, 08:44 PM
v0xb0x's Avatar
v0xb0x v0xb0x is offline
 
Join Date: Jun 2008
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
# Sanitize the variables, all of them are unsigned integers
$vbulletin->input->clean_array_gpc('r', array('c' => TYPE_UINT'e' => TYPE_UINT'g' => TYPE_UINT)); 
Here's what we have in the header template:

HTML Code:
<a href="/forums/forumdisplay.php?f={$vbulletin->GPC['e']}">
...which is being evaluated correctly as:

HTML Code:
<a href="/forums/forumdisplay.php?f=2">
Outstanding!

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?
Reply With Quote
  #18  
Old 07-01-2008, 03:28 AM
lendelgan@gmail lendelgan@gmail is offline
 
Join Date: Jun 2008
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, I am having trouble with this same thing.

I have:

PHP Code:
$globals = array(
    
'a'    => TYPE_UINT,
    
'b'    => TYPE_UINT,
    
'c'     => TYPE_NOHTML,
);
$vbulletin->input->clean_array_gpc('r',$globals); 
(this gets accessed like: script.php?a=3&b=4&c=some+Value)
later I have
PHP Code:
$x $vbulletin->GPC['a']; 
however:
PHP Code:
echo $x
returns nothing but when we do
PHP Code:
print_r($vbulletin->GPC);
$x $vbulletin->GPC['a'];
echo 
$x
The value (3) gets returned.

this is irritating, because I can't figure out when the variable will be set and when it won't.

For
PHP Code:
$x $vbulletin->GPC['c'];
echo 
$x
Works fine. If someone could tell me what I am doing wrong I would appreciate it.
Reply With Quote
  #19  
Old 07-01-2008, 06:58 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make sure you globalise $vbulletin if calling from inside a function.
Reply With Quote
  #20  
Old 08-25-2008, 05:29 AM
mooreaa mooreaa is offline
 
Join Date: Aug 2008
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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 05:56 PM.


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.11564 seconds
  • Memory Usage 2,287KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_html
  • (11)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
  • (10)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_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