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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2012, 06:13 PM
SToP_GAP SToP_GAP is offline
 
Join Date: May 2012
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How can I insert new fields within an existing admin form via plugin/hooks?

Hi, I hope someone can help...

I'm trying to extend the forum.php admin form by adding a few custom fields in there. I won't get into what those will be and explaining all that... basically if someone could show me how to add a direct copy of the "Title" field directly after that in the forum this would be most helpful.

Line 140 of forum.php is:

PHP Code:
print_input_row($vbphrase['title'], 'forum[title]'$forum['title']); 
I have a product & plugin defined and using the "forumadmin_edit_form" hook I can execute code just fine. What I can't work out is how to "inject" at a certain point in the output.

Essentially if I were hard editing the forum.php file, then I would copy line 140 and paste it again as line 141. How do I achieve the same from a plugin?

Many thanks
Reply With Quote
  #2  
Old 09-20-2012, 08:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately, you can't. The adminCP works differently than the forum in that it doesn't use templates and just outputs html as it goes along instead of once at the end, so there's no chance to change it via str_replace() or anything like that. The best you can do (without editing the file) is to use hook forumadmin_edit_form and add it at the end. (It's fortunate that forum.php has hooks at all, a lot of the adminCP doesn't).
Reply With Quote
  #3  
Old 09-21-2012, 02:52 PM
SToP_GAP SToP_GAP is offline
 
Join Date: May 2012
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, thanks for that, you saved me a lot of time wrestling with it trying to work out why it wasn't working!

For anyone else having the same issue, I found a slightly bodgy but nonetheless useful way to get this functionality (on this particular page at least). Using the earlier hook "forumadmin_start" I set the output buffering of PHP on (using ob_start() )

Then in the section where I needed to make a change, I accessed the contect of the buffer using $stringvar = ob_ get_ clean(). With a combination of this and nested output buffers I was able to do exactly what I needed.

This required a plugin for both the "forumadmin_start" hook (which turns on the buffer) and then a separate plugin at the hook point where I'm dealing with the buffered output, in this case "forumadmin_edit_form".

This is not perhaps advisable for mainstream pages as it'll introduce additional overheads on a system, but for backend pages it shouldn't cause any issues. There is potential to clash with other plugins which manipulate the page at the same time as this, especially if they do anything with the buffer so tread carefully.
Reply With Quote
Благодарность от:
kh99
  #4  
Old 09-21-2012, 04:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice - wish I'd thought of that.
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 03:33 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.05308 seconds
  • Memory Usage 2,194KB
  • 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
  • (4)post_thanks_box
  • (1)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete