vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How do I set a $_REQUEST variable so that an included vB script will use it? (https://vborg.vbsupport.ru/showthread.php?t=135776)

Spinball 01-07-2007 12:02 PM

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

RedTyger 01-07-2007 12:59 PM

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.

Spinball 01-07-2007 01:16 PM

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 :))

RedTyger 01-07-2007 01:30 PM

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.

Spinball 01-07-2007 01:52 PM

Quote:

Originally Posted by RedTyger (Post 1152606)
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.

Paul M 01-07-2007 02:05 PM

PHP Code:

$threadid 123;
include_once(
"path/to/showthread_inline.php"); 


Spinball 01-07-2007 02:59 PM

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?

Kirk Y 01-07-2007 04:18 PM

Code:

eval('$var = "' . fetch_template('SHOWTHREAD_inline') . '";');

Spinball 01-07-2007 05:10 PM

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

Paul M 01-07-2007 05:41 PM

Add

PHP Code:

global $vbulletin 

to the top of your function.


All times are GMT. The time now is 01:16 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
  • Page Generation 0.02309 seconds
  • Memory Usage 1,747KB
  • 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
  • (5)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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