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 01-03-2013, 03:33 PM
dog-tag's Avatar
dog-tag dog-tag is offline
 
Join Date: Jan 2012
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How To Place PHP Inside A Standard Phrase

Hi,

I'm venturing deeper into vBulletin and I'm wondering if this is possible.

I want to put a PHP script inside a standard phrase (its $vbphrase[registeremail] if you're wondering)

Now I know I can put this PHP script into a plugin (I think they're also called hooks??) and then call it that way.
But how would I call up the plugin like that? What is the code I'm suppose to use?

And also why can't I just paste in the PHP code straight into a phrase? Is this possible or does it conflict?

Any pointers are appreciated, I've been trying to learn all day how vBulletin works in alot greater detail.

Gilesy
Reply With Quote
  #2  
Old 01-03-2013, 05:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't say that I'm an expert on vbulletin phrases, but my take is this: they're really just strings that are saved in the database, and what you are allowed to put in them is determined by how they're used. For most I'd say that they're just used as part of the output and so they can include html. But I think some others (email subject and bodies, for example) are used as plain text and are run through eval() as a double quoted string, so they can include variables that will get be evaluated. So I guess the answer to your question would be that you *could* create a phrase that included php, but that I don't know of any in vbulletin that allow it - I don't think there's any way to include php in any of the existing phrases and expect it to run.

Anyway, I hope that helps. Feel free of course to ask for more if that doesn't help.
Reply With Quote
  #3  
Old 01-03-2013, 06:28 PM
dog-tag's Avatar
dog-tag dog-tag is offline
 
Join Date: Jan 2012
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks alot Kevin!

OK, well I can narrow down then that I can't just paste in PHP into a phrase, I tried it and it half came out right, with an error.

I think then what I'm suppose to do is put my PHP into a hook...
Can a phrase call a hook? Or is a phrase just a phrase for looking at?

If that isn't possible, then I need to put this hook into the correct template that is being called. In my case its the standard_error template (I'm pretty sure).

Problem is it will be used for all errors, so I'll need to learn then how to use an IF command after I see it working correctly!?

Do you think I'm on the right track? Thanks for replying to me, its hard to understand all this code at the start, vbulletin is a strange animal, (I tried liking your post Kevin but the forum won't let me.)
Reply With Quote
  #4  
Old 01-03-2013, 06:51 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dog-tag View Post
I think then what I'm suppose to do is put my PHP into a hook...
Can a phrase call a hook? Or is a phrase just a phrase for looking at?
Phrases are pretty much just for looking at. The purpose really is to allow language changes by avoiding 'hard-coding' text anywhere.

A plugin is some php code that gets executed at a certain point in the vbulletin code, so that might be what you want. You can look at a vbulletin script and see where the plugins are executed. For example, if you look at showthread.php line 118 (in vb4.2.0 PL2), there's this:
Code:
($hook = vBulletinHook::fetch_hook('showthread_start')) ? eval($hook) : false;

That gets all the plugin code for hook location 'showthread_start' and executes it by calling eval. I think it can be confusing to newcomers (as it was to me) because it seems like there should be documentation of what you can do at different hook locations, but really they're just selected points in the vbulletin scripts, and what you can do at each one depends on how that script is written. So it's kind of like a puzzle sometimes to figure out how to get things done using just plugins. Of course there's no real reason you couldn't just modify the vbulletin files to do whatever you want, except that when you want to upgrade you'd have to edit the files again.



Quote:
If that isn't possible, then I need to put this hook into the correct template that is being called. In my case its the standard_error template (I'm pretty sure).

Problem is it will be used for all errors, so I'll need to learn then how to use an IF command after I see it working correctly!?

Do you think I'm on the right track? Thanks for replying to me, its hard to understand all this code at the start, vbulletin is a strange animal, (I tried liking your post Kevin but the forum won't let me.)

You might be able to use a plugin, but it depends on exactly what you're trying to do. Another possibility is to edit the template and use <vb:if>...<vb:else />..</vb:if> tags, but what you can do there is limited so a lot of times you also need a plugin to set up the variables you need. (Edit: here's the onlien manual: http://www.vbulletin.com/manual/ . If you haven't looked at it already, you might want to search for "template syntax" and "adding plugin" (select your vb version fromthe dropdown before searching).


I know it's confusing. It's hard to explain it in a short space (well, hard for me. Maybe someone else can do a better job).
Reply With Quote
  #5  
Old 01-05-2013, 10:46 AM
dog-tag's Avatar
dog-tag dog-tag is offline
 
Join Date: Jan 2012
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Kevin you're a proper life saver!

I understand what I need to know now, I'm going to learn the IF commands a bit better and play about in a template that is not being used.

Pretty sure I just need to start experimenting a bit more and getting my coding hands dirty!
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 07:27 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.03671 seconds
  • Memory Usage 2,201KB
  • Queries Executed 11 (?)
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_code
  • (2)bbcode_quote
  • (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_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