Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2009, 05:23 PM
ButtKrust ButtKrust is offline
 
Join Date: Feb 2009
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Getting forum ID through php?

I was wondering how you go about getting the forum ID put into a variable or even just echo'd through PHP. Does it have anything to do with using the $_REQUEST['forumid']? Could someone give me a short code sample of how to echo a forum ID through PHP or point me to a topic that does? Just using "echo $_REQUEST['forumid']" doesn't work. I've tried searching but I can't find anything specific to what i need. thanks.
Reply With Quote
  #2  
Old 03-01-2009, 05:30 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It depends on where you are using the variable. Most people use it in a template and you can see all the places it is used in a template by doing a Search In Templates for "forumid" (no quotes). Note that the exact name of the variable is different depending on what template it is used in.
Reply With Quote
  #3  
Old 03-01-2009, 05:32 PM
ButtKrust ButtKrust is offline
 
Join Date: Feb 2009
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm actually using it in a .php file which is displayed by a vbadvanced module. Would i need to connect to my database and pull the forum id from there instead? $foruminfo[forumid] isn't working.

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

Actually when i put require_once('./global.php'); at the top of the page, i can get "echo $_REQUEST['forumid'];" to display '0', but not '5' which is the actualy forum id. Any ideas?
Reply With Quote
  #4  
Old 03-01-2009, 05:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you tried just $forumid? And, what are you getting the forumid *of*? That is the clue to actually getting it because you need to pull it from whatever query you are using. Unless you are actually in a forum, you won't have a forumid of anything unless you query for it.
Reply With Quote
  #5  
Old 03-01-2009, 05:55 PM
ButtKrust ButtKrust is offline
 
Join Date: Feb 2009
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$forumid didn't work. I'm trying to get the forum ID of the forum that contains the module with this php file. I tried having it connect to the database and use "SELECT forumid FROM forum" but this output "Recource id #3" instead of '5', which again is the actual forum id that contains the module. I think i'm getting myself way off track...
Reply With Quote
  #6  
Old 03-01-2009, 06:15 PM
Mr-Moo Mr-Moo is offline
 
Join Date: Sep 2007
Location: Chicago, IL.
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Would you mind clarifying your entire objective a little more? After reading this Lynne has provided a solution, but I don't quite understand what you are looking for.

// Edit //
Is the forumID static or dynamic? What are the conditions?
Reply With Quote
  #7  
Old 03-01-2009, 06:21 PM
ButtKrust ButtKrust is offline
 
Join Date: Feb 2009
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright I am using vbadvanced. I have a module of my forum which outputs a .php file. In this php file, i would like to find out the forum id in order that i might display something specific to each forum in that module. Just to keep things simple, though, i would like to echo or assign to a variable the forum ID that contains this module and php file. Basically when the page is loaded and the php file is loaded i want it to check the forum id so that i can set specific functions based on that forum id.
Reply With Quote
  #8  
Old 03-01-2009, 06:37 PM
Mr-Moo Mr-Moo is offline
 
Join Date: Sep 2007
Location: Chicago, IL.
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I am not mistaken you are looking for something that does the following:

-When the forum page loads it checks the ForumID.
-If the forum ID matches a specific command, it outputs X item.

If this is what you are looking for, this is just a simple if else function.

PHP Code:
<?php
if ($forumid 1)
{
echo 
"Your desired output";
}
elseif (
$forumid 2)
{
echo 
"Desired output for 2";
}
else
{
echo 
"Desired output for FALSE";
}
?>
Reply With Quote
  #9  
Old 03-01-2009, 06:41 PM
ButtKrust ButtKrust is offline
 
Join Date: Feb 2009
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$forumid decided to start working, i guess i missed it earlier. This is exactly what i needed, thank you both very much and i'm very sorry for misunderstanding so much.
Reply With Quote
  #10  
Old 03-01-2009, 06:42 PM
Mr-Moo Mr-Moo is offline
 
Join Date: Sep 2007
Location: Chicago, IL.
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem, was my code of any assistance, or were you simply in need of the $forumid portion?
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 03:02 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.04813 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
  • (1)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
  • (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_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