Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2011, 01:57 AM
Valcav Valcav is offline
 
Join Date: Nov 2010
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I add an option in a plugin?

Hello,

I created a product,
I created a plugin,

in that plugin I have some php-code...
PHP Code:
if (in_array($threadinfo['forumid'], array(69))) 
& a little bit further
PHP Code:
 $dest_id 70
What I want to do now,
Is having a button for my product on the left side,
and in there a button called "options" or something similar.
when you click on that, on the right side:

News Thread Forum ID:
(Enter the forum id where the News thread will be made)
&
News Discussions Thread Forum ID:
(Enter the forum id where the News Discussions thread will be made)

So what do I need to do to change that "69" so whatever number is filled in the "News Thread Forum ID" is used there...
And what do I need to change that "70" so whatever number is filled in the "News Discussions Thread Forum ID" is used there...


(You can call me lazy for not reading enough of documentations, I'm just a little bit to impatient for reading)

Friendly greetings,
and thanks in advance
Valcav
Reply With Quote
  #2  
Old 12-18-2011, 03:06 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To put a menu on the left in the adminCP, look at the files in the includes/xml directory. If you create an xml file starting with "cpnav_" and put it in that directory, you can create your own menu. For the right side, you will need to create your own script. Probably the easiest thing to do would be to look at the existing scripts in the admincp directory and see how they work.

An easier way is to add your options to the existing options page by putting the site in debug mode. When you do that, extra controls will appear that will allow you to add sections and options (Add Option link at the top of each section). When you do that you choose a Varname, and then in your plugin code you can use $vbulleton->options['varname'] to get your value.
Reply With Quote
  #3  
Old 12-18-2011, 01:46 PM
Valcav Valcav is offline
 
Join Date: Nov 2010
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
To put a menu on the left in the adminCP, look at the files in the includes/xml directory. If you create an xml file starting with "cpnav_" and put it in that directory, you can create your own menu. For the right side, you will need to create your own script. Probably the easiest thing to do would be to look at the existing scripts in the admincp directory and see how they work.

An easier way is to add your options to the existing options page by putting the site in debug mode. When you do that, extra controls will appear that will allow you to add sections and options (Add Option link at the top of each section). When you do that you choose a Varname, and then in your plugin code you can use $vbulleton->options['varname'] to get your value.
I put it in debug mode,
Setting Group: Valcavs Auto Copy Threads To Discussion Forum (id: valcav_news_discussion)
Added 2 settings:
Setting: News Thread Forum ID: (id: valcav_news_discussion_news_id)
Default: 69
Positive Integer
&
Setting: News Discussions Thread Forum ID: (id: valcav_news_discussion_discussion_id)
Default: 70
Positive Integer

So now I have to change:
PHP Code:
if (in_array($threadinfo['forumid'], array(69))) 
into
PHP Code:
if (in_array($threadinfo['forumid'], array($vbulletin->options['valcav_news_discussion_news_id']))) 
&
PHP Code:
 $dest_id 70
into
PHP Code:
 $dest_id $vbulletin->options['valcav_news_discussion_discussion_id']; 
???

Friendly greetings,
Valcav
(& thanks for your help)
Reply With Quote
  #4  
Old 12-18-2011, 01:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's looks right to me. You may also need to add

Code:
global $vbulletin;

before you use $vbulletin, depending on the hook location.
Reply With Quote
  #5  
Old 12-18-2011, 06:12 PM
Valcav Valcav is offline
 
Join Date: Nov 2010
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
That's looks right to me. You may also need to add

Code:
global $vbulletin;

before you use $vbulletin, depending on the hook location.
Can/could it hurt if that code is standing twice in that "Plugin PHP Code"?
Reply With Quote
  #6  
Old 12-18-2011, 06:14 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Valcav View Post
Can/could it hurt if that code is standing twice in that "Plugin PHP Code"?
No, you can have that twice, so it's OK if you want to put it in just to make sure.
Reply With Quote
  #7  
Old 12-18-2011, 09:09 PM
Valcav Valcav is offline
 
Join Date: Nov 2010
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much for the help!
Reply With Quote
  #8  
Old 01-01-2012, 03:30 AM
Mr_Running Mr_Running is offline
 
Join Date: May 2010
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What was the end result...code?
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 01: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.05079 seconds
  • Memory Usage 2,246KB
  • 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_code
  • (6)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete