The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[vBulletin 4] Simple way of including an external PHP file
There are other articles out there on variables, templates, etc on vBulletin 4. This is a simple example of including an external PHP files like you used to be able to do here: http://www.vbulletin.com/forum/showt...P-or-HTML-File Thanks to this Blog post by David IB http://www.vbulletin.com/forum/entry...s-to-templates and this article by cellarius https://vborg.vbsupport.ru/showthread.php?t=228078 I have figured out it's only a simple extra step. Step 1: Create a new plugin
Step 2: You will have to figure out these two entries for yourself: LOCATION OF EXTERNAL FILE & Hook Location To give you an example of what you should use is that if you want to display your external PHP file on your Forum's Home. Then replace these two with these values: Hook Location with forumhome_start TEMPLATE YOU ARE USING with FORUMHOME Keep in mind that global_start will still be acceptable, but it's extra loading time where it's not needed. Therefore choosing the optimum hook location is better for your performance overall. Step 3: Visit the Style Manager -> TEMPLATE YOU ARE USING and place the variable in your style where you want it. You will have to use the new format. Code:
{vb:raw php_include} Notes, If you want to: Include this PHP file in multiple templates then preRegister it for the multiple templates: Code:
vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include)); vB_Template::preRegister('TEMPLATE YOU ARE USING 2',array('php_include' => $php_include)); I'm still learning as I go with vb4, but if I learn some more notes to add... I'll drop by here. I hope that helps some one out there! |
#52
|
|||
|
|||
I am using this hack to include a few php pages as it is intended. Everything works great, other than I cannot get form submits to work. I get a "Your submission could not be processed because a security token was missing."
I've looked around on the forum trying to find an answer, but I can't seem to find one. How can I correct this? Thanks. |
#53
|
|||
|
|||
Hello,
I'm on 4.1.2 and I used the code mentioned above to vb 4 PHP Code:
PHP Code:
Or is the problem? Thank you |
#54
|
|||
|
|||
Can i put a VB variable in that php file such as {vb:raw totalthreads} ? I tried but not sucess
|
#55
|
||||
|
||||
In a plugin or php file it would be $totalthreads. The {vb:raw ...} is only for use when displaying contents in a template.
|
#56
|
|||
|
|||
I could also use some help on including php file into a template.
I have a template with an header, a navbar, the forum/content, footer and a fixed right bar. I wan't to insert this php code(for now) into the right bar: userbox.php PHP Code:
PHP Code:
PHP Code:
The HOOK is parse_templates. When i in the plugin write echo $userboxinsert; the userbox get's inserted but at the top of the screen, so the link works. Would be very happy if someone could help me with this problem! |
#57
|
||||
|
||||
Total programming n00b here... asking for help
I just came here find out how to get a php-script to run, and was really glad to see you guys already had a page on the issue. My idea is fairly simple: I picked up a rotator script (php) and will upload to it's own directory (/rotator). I intend to have several copies (e.g. games.php, religion.php, cars.php, gadgets.php) and each script points to a different sub-directory, e.g. /games, /religion, /cars, /gadgets, etc.) From there, in the last post of every thread I want to call it but will use an IF THEN to dictate which version it calls. (e.g. IF forum=12 then call cars.php, else if forum=15 then call gadgets.php) <vb:if condition="$GLOBALS['forumid'] == 63 OR $GLOBALS['forumid'] == 54 OR $GLOBALS['forumid'] == 56"> [not sure what to put here in order to call 'games.php'] <vb:if> <vb:if condition="$GLOBALS['forumid'] == 3"> [not sure what to put here to call 'cars.php'] <vb:if> This in turn should then reflect relevant files for specific forum content. I suspect the IF THEN will be placed in the template 'ad_thread_last_post_content' (or via the Advertising/Manage Ads script within ACP). I'm uncertain what hook I could use for this (these would only show on SHOWTHREAD templates - or is postbit_legacy as it's only in the last post?). I will later be adding a similar function to the bottom of specific forums to show different rotator scripts (different sized affiliates). Any chance of a bit advice for getting this off the ground? |
#58
|
||||
|
||||
When you say "call" do you mean "display"? Is cars.php a page you can view with content if you browse to it?
If so I think what you are looking for is an IFRAME... the basic syntax would be: Code:
<IFRAME SRC="http://domain.com/rotator/cars/cars.php" WIDTH="100%" HEIGHT="50"></IFRAME> You can search google for more options on the IFRAME tag. |
#59
|
||||
|
||||
Although an iframe would suffice (thanks, I hadn't even given it a thought), I was under the impression I could an external php file from within a template..?
I'd prefer to do it as a display/call than within an iframe (which would not show to some browsers). In worst case scenario though, i'll go with an iframe. |
#60
|
||||
|
||||
I just don't know what you mean by "call" a php file then... You can't do that from a template. You could do it from a plugin but again you're not "calling" a file. You can call a function in a file, but if you want to display output from the php file in a specific location you need to make a template for that file.
|
#61
|
||||
|
||||
Quote:
Anyway, my idea is to: 1) breakdown forum into separate categories (e.g. religion, cars, games, etc.) 2) in the last post, 'refer to' a specific script. 2a) e.g. religion forum would refer to a script renamed as 'religion.php' 2b) cars forum would refer to a script renamed as 'cars.php' 3) the scripts within each above file would be the same, but refer to different text files. 4) the cars forum & script would then extract data from the text file for cars, which would ultimately show to the end-user as a affiliate image/link specific to cars. 4b) exactly the same as 4) but with religion context instead, so 'christian stuff' would show up in the religion forum (and other religions too). so when a guest comes to my forum and visits the car section, they'll see links and/or images in the final post which will be pertinent to cars... if they swap over to the religion forum (or games or anything else) they will see the last post giving links/images relevant to those forums too. |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|