Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2003, 08:11 PM
stryka stryka is offline
 
Join Date: Aug 2002
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trick to using VB variables on Non-vb pages...

Ok...

Do i have to use ECHO commands in order to use the variables within GLOBAL.php?

I thought it was simple as this...
<html>
<?
require("global.php");

?>

<p> Hello... my name is $username</>

</html>

but... i assume you have to do the following:

<html>
<?
require("global.php");

echo('<p> Hello... my name is $username</>');
?>
</html>

Is there an easier way... what is the right way? I want learn to code indpependent pages of VB but use the VB variables.... if the echo command is the only way then so be it... but I do a visual/code upgrade every 6 months and the echo command may seem to be bit too much...

Everyone has asked this question... and the response is just use GLOBAL.php and sessions in the url... etc... but how... write out some sample code for the newbies.... and once we learn how we will do the same...

Thanx
Reply With Quote
  #2  
Old 01-18-2003, 08:16 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Firstly only require global.php once at the top of the page, then you have all of the vB variables and functions avalible to you:

PHP Code:
<?php
require("./global.php");
?>
<html>
<body>
<p> Hello... my name is <?php echo $bbuserinfo[username]; ?></p>
</body>
</html>
Reply With Quote
  #3  
Old 01-18-2003, 10:28 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmmmm, not quite. If the file that is calling global is outside of the forum tree then global.php is going to bomb out as soon as it starts hitting the require()'s. I'd like to know if there's an abstraction method to get accurate paths all the time, whether global.php is being called within the directory tree as in vBulletin or if it'bs being called from outside.

Aaron
Reply With Quote
  #4  
Old 01-18-2003, 10:30 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why not put ./forum/global.php ?? soz just my thought i dont even know php lol
Reply With Quote
  #5  
Old 01-19-2003, 01:11 AM
Davey Davey is offline
 
Join Date: Nov 2002
Location: England
Posts: 383
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually that doesn't work in the slightest.
In my /public/ directory, I want my index page.
/vB/global.php is the location of global.php from my index page, and this is what I used:
PHP Code:
<?php
require("./vB/global.php");
?>
<html>
    <body>
        <?php
            $bbuser1 
$bbuserinfo['username'];
            echo 
"You are logged in as $bbuser1.";
        
?>
    </body>
</html>
Returns blank page...
Reply With Quote
  #6  
Old 01-19-2003, 01:35 AM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yup, exactly. change the filename to global2.php and you'll get an error that it can't find the include path. when it's just global.php there's no error so you have the right path and file. Problem is the require()'s. require is similar to include() but when require() returns false it immediatley ends all execution of the php. It just ends.

Now you could replace all the require()'s with include()'s but you'll still get errors because basically the file being called is not inexistence...because it's calling it fropm your external page path and noth the vb page it was meant to be called from. If it was called from a vb page it would return true, but if not, it returns false thus breaking the script. This is also why require() exits. Because the files being require()d are non-existent.

There has to be another way.
Aaron
Reply With Quote
  #7  
Old 01-19-2003, 01:38 AM
Davey Davey is offline
 
Join Date: Nov 2002
Location: England
Posts: 383
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well if you understand that, surely you know how to get around it...
Reply With Quote
  #8  
Old 01-19-2003, 04:26 AM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I suppose that's why I'm wasting my time on these forums. :rolleyeyes:

I've just spent the better part of a day importing an ikonboard to vB. I really don't need that.

If I knew what to do I wouldn't be asking.

I mean, sure I could change the require()'s to include()s but that doesn't solve the path problem, and if I fix the path problem it;s bound to cause problems elsewhere.

That's why I'm asking....how would YOU do it? And please, no bull++++ answer. If you don't know, say that. If you do, don't play games, just tell me.

Thanks

Aaron
Reply With Quote
  #9  
Old 01-19-2003, 05:14 AM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well if you just want to use the $bbuserinfo variables coudln't you copy the global.php to the folder your using your index.php in? im not sure, just a thought
Reply With Quote
  #10  
Old 01-19-2003, 05:59 AM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wouldn't fix paths. I'd have to copy EVERYTHING over or at leas tthe files it's trying to include. That just doesn't seem like a valid solution to me.

Aaron
Reply With Quote
Reply

Thread Tools
Display Modes

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 06:21 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.07619 seconds
  • Memory Usage 2,252KB
  • Queries Executed 13 (?)
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_php
  • (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_postinfo_query
  • fetch_postinfo
  • 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