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 01-07-2007, 12:02 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I set a $_REQUEST variable so that an included vB script will use it?

I am trying to display a thread (minus the header/footer and some other bits) in a webpage on the same server as my vB installation.
I have created a cut-down version of SHOWTHREAD template called SHOWTHREAD_inline.
I have made a copy of showthread.php to showthread_inline.php and changed it to use the SHOWTHREAD_inline template.
I have then included showthread_inline.php into my custom php script.

It works but just shows the 'no thread specified' error. I can't set the ID of the thread I want to display.
I have tried :
PHP Code:
$_REQUEST['t'] = 123456;
include_once(
"path/to/showthread_inline.php"); 
but the value of t is not taken into the included code.

How do I do this, please?
Thanks
Reply With Quote
  #2  
Old 01-07-2007, 12:59 PM
RedTyger's Avatar
RedTyger RedTyger is offline
 
Join Date: Nov 2006
Location: UK
Posts: 1,310
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
if ($_REQUEST['t'] == '123456')
{
include_once("path/to/showthread_inline.php"); 
}
Should do the trick. Note the == instead of the = you had.

= means This is now the same as That.
== means This has the value of That.
Reply With Quote
  #3  
Old 01-07-2007, 01:16 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for replying but you've got the wrong end of the stick.
What I need to know is how to have the showthread_inline.php script pick up on the value of the thread id.
Assigning $_REQUEST['t'] to it's value before including the code doesn't work.
THis is my test script:
PHP Code:
chdir("/home/sites/avforums/public_html/forums");
$_REQUEST['t'] = 452805;
include(
"/home/sites/avforums/public_html/forums/showthread_inline.php"); 
which just displays the 'No Thread specified' error.
I have looked at some of the vB code to see where request variables are 'received' to get a clue on how to do this. I have looked in init.php and global.php but don't see any sign of such code.

(P.S.
Quote:
= means This is now the same as That.
== means This has the value of That.
No offense but I've been programming computers for 25 years )
Reply With Quote
  #4  
Old 01-07-2007, 01:30 PM
RedTyger's Avatar
RedTyger RedTyger is offline
 
Join Date: Nov 2006
Location: UK
Posts: 1,310
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh I see. Request variables come from the URL itself. Look at the URL for this page, it'll either have a t (thread) or p (post) variable. Request is like POST or GET but with a few extras thrown in.
Reply With Quote
  #5  
Old 01-07-2007, 01:52 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RedTyger View Post
Oh I see. Request variables come from the URL itself. Look at the URL for this page, it'll either have a t (thread) or p (post) variable. Request is like POST or GET but with a few extras thrown in.
Yes I'm aware of all that. I'm trying to do something different.
As I stated in my first post, I'm trying to include a (only slightly modified) version of showthread.php within my own php script. I want to send it a specific thread id.
Reply With Quote
  #6  
Old 01-07-2007, 02:05 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$threadid 123;
include_once(
"path/to/showthread_inline.php"); 
Reply With Quote
  #7  
Old 01-07-2007, 02:59 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bingo!.
Who could possibly have thought it would be as blindingly simple as that!
Cheers, Paul.

Supplemental question.
Rather than using
PHP Code:
eval('print_output("' fetch_template('SHOWTHREAD_inline') . '");'); 
To output the page immediately, is there a quick way to assign it to a string for incorporation into my own web page?
Reply With Quote
  #8  
Old 01-07-2007, 04:18 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
eval('$var = "' . fetch_template('SHOWTHREAD_inline') . '";');
Reply With Quote
  #9  
Old 01-07-2007, 05:10 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome! Thanks - I'm nearly there.
Implementing into the website, now and I'm getting a problem because I'm including the showthread_inline.php script within a function. (I don't have any choice at this point).
I get an error:

Quote:
Fatal error: Call to a member function on a non-object in /home/sites/avforums/public_html/forums/global.php on line 22
I don't get the same error when including it in the main code (rather than a function).
Is there any way I can include it within a function?
Many thanks
Reply With Quote
  #10  
Old 01-07-2007, 05:41 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add

PHP Code:
global $vbulletin 
to the top of your function.
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 10:17 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.08641 seconds
  • Memory Usage 2,264KB
  • 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
  • (2)bbcode_code
  • (5)bbcode_php
  • (3)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
  • (1)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