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 06-27-2013, 10:12 PM
QSTR QSTR is offline
 
Join Date: Nov 2010
Location: Poland
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Right way to install custom PHP code in the core vB PHP files

Hello everyone,

I've made a 'plugin' for my community (couple custom PHP files, some templates and tables)
All is working great BUT.

In order to use this plugin I need to add piece of code to the 'newthread.php' file, in this place (VB 4.1.12 PL3:
Code:
271         else
272         {
                      // something to do here
292 
293                 // ### NOT PREVIEW - ACTUAL POST ###
294                 $threadinfo = fetch_threadinfo($newpost['threadid']); // need the forumread variable from this
I've made it via VIM but I think this is not right way to do it (if I use diagnostics, vB says this file is not OK )
So, is there any easy way to install this code exactly in this place via some feature in Admin Panel?

Or if there is no 'easy and nice way' to do this, tell me please if will it be any problem for vB when I leave this code there. (during installation/deinstallation of products? [i know about vB upgrades, when I need to fe. update the newthread.php file])

Thank you.
/sorry for my english/
Reply With Quote
  #2  
Old 06-27-2013, 10:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you can't figure out a way to do it using the existing hook locations, then you have no choice but to change the files. There isn't any way to do it from the admincp, so what you have done is ok. Vbulletin will tell you the file has been changed because that's what the feature does - it tells you if any files have been changed from the original. It won't cause any problems other than being reported as changed.
Reply With Quote
  #3  
Old 06-27-2013, 10:31 PM
QSTR QSTR is offline
 
Join Date: Nov 2010
Location: Poland
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okey, I got this.
I rly do not care about diagnostics - just checked it for fun.

I'm very happy there will be no problems - this is important for me.

Thanks for the fast answer.
Maybe sometime I'll study the hook engine, for now I will stay with my old-school 'hand made' style.

Best regards from Poland
Case closed.
Reply With Quote
  #4  
Old 06-27-2013, 10:36 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I thought maybe you had already looked for hook locations. It turns out there's one a couple lines after the "something to do here", so if it's not important to do it before those two lines, you might be able to use a plugin. In case you want to try, it would be hook location newthread_post_complete.
Reply With Quote
  #5  
Old 06-27-2013, 10:44 PM
QSTR QSTR is offline
 
Join Date: Nov 2010
Location: Poland
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Don't know what to say, but I moved this piece of code from 'newthread.php' to the new plugin with location newthread_post_complete and it's working.
So good software.
Your hint was very helpful for me.

Funny, because as you said the code:
Code:
($hook = vBulletinHook::fetch_hook('newthread_post_complete')) ? eval($hook) : false;
...is just below.

Very nice, 'newthread.php' restored and all is great.
Found the right way

Thank you very much.

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

/edit/
Didn't know this might be so easy.
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:42 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.03925 seconds
  • Memory Usage 2,199KB
  • 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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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