![]() |
Insert HTML or (pre-processed!) PHP file above specific forum
This is a very simple but very powerful hack for VB 3 which I've not been able to find elsewhere so decided to write.
It inserts a named external file (or files) above a specific forum (or forums). I use it to insert some HTML from HTML AND PHP (!) files above specific forums. It works perfectly on my forums with over 28,000 members. It requires editing one file and one template. The amazing thing I discovered is that if the php function used (file_get_contents) is used on a php file, the php is processed BEFORE the file contents are read into the string. The first attached image shows this hack 'including' a php file which dynamically builds a list from a database on a different server into a drop-down list box. The second image shows the inclusion of a banner and beneath it a HTML file showing latest news (which is created automatically). * Updated August 7 2004. Altered the text file to include instructions on how to insert the file at the top of your forum list *. Please note that the forum list instructions are untested. If someone uses it, please let me know if it works ok. One question, though. This hack is so simple but so powerful, howcome nobody has done it before? Or have they already? |
How to use this hack to display rotating banners.
You can use the above hack on a php script to create any number of rotating banners above your forums (without any modification to the forum table as per other hacks). Create a .php file as follows: PHP Code:
Upload this php file to your server and have the above hack open it. If you want to display the same set of banners on several forums, just have them open this file. If you want a different set of banners you'll need to create a different version of this file for each. Other notes: The reason for calling the perl scripts is so that a hit stats package like Webtrends can count the number of times the perl scrips have been run and provide you with the number of clicks for your banners in it's report. A typical perl script would look like this: HTML Code:
#!/usr/bin/perl PHP Code:
-------------------------------------------------------------------------------------------------- Give users a control panel option to change how the added information is displayed I use this hack to include different news feed above certain forums but some users wanted it displayed at the bottom or not at all. This is very easy and thanks to Colin F who helped me. First create a new user option. I'll use my installation as an example. Admin CP > User Profile Fields > Add New User Profile Field. For the Profile field type choose Single Selection Radio Buttons or Single Selection Menu whichever you prefer. I chose the latter since it looks more similar to existing multiple choice user options. Complete the new profile field information. My forum users use this profile field to decide how to display the news and I set the Options to Above threads Below threads Not shown I set the default to Yes, but No First Blank Option. And the field IS required. Lastly for the display page 'Which page displays this option?' choose Options: other. Ok, now you have the new profile field. Take a look at the list of User Profile Fields in the User Profile Field Manager to find which field your new option is. Mine was field9. Now all you have to do is edit the FORUMDISPLAY template. Below $navbar insert ------------------- <if condition="$mycustomheader AND $bbuserinfo[field9] == 'Above threads'">$mycustomheader</if> ------------------- Note that this is the original hack altered to display the $customheader information IF the user has chosen to display it above threads. -------------------- Then below ------------------------------ <!-- ############## END THREADS LIST ############## --> </if> ------------------------------- Insert ------------------------------ <if condition="$mycustomheader AND $bbuserinfo[field9] == 'Below threads'">$mycustomheader</if> ------------------------------ Note that if users have chosen the third option 'Not shown', then the $mycustomheader information is never shown :) |
Is this also working for the forumhome?
I want to add a small table right unter the navbar and want to phpinclude a file there. |
Yes it will.
Instructions added into the text file August 7 2004. |
thanx for this cool hack , and it will be great if you make it for vbulletin 2.x.x people
:) |
Quote:
I don't run vb2 any more so if someone would like to have a look and let me know, I'll add it to the instructions. |
thank you again :)
|
I recieved this error after following your instructions:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/myfolder/forums/forumdisplay.php on line 372 Is there something wrong with your file? in your instructions for setting up on forumhome, it seems to be for calling up the file in a specific forum, maybe i am missing something here? how do i have the banners show up on every page? |
Quote:
Is this the source of your error? If not what is the line at 372 in your file? |
|
Can you use this mod to pull in the Latest Topics mod used in the portal? Or is there a way to pull in the latest topics/posts without using the portal mod?
I'm very new to VB and PHP so any help is greatly appreicated. I am trying to put the most recent topics/posts at the top of the forum and get it scroll when moused over...I'm having a devil of a time figuring this out. |
Not familiar with the Latest Topics mod and don't have time right now to investigate.
I would imagine that nearly anything is possible with a little coding. |
I've added this, and it looks very good. I just have a couple questions. How do I center the image on top of my forum list? It is far left right now. Also, I can't seem to get the images links to work. I have been playing with it for a while and can't seem to figure out how to get the perl scripts working, or even functional.
thanks for your help! |
you can wrap your banner/link in a div:
<div style="text-align:center;"> <a href......>banner</a> </div> .... i don't know about the links. It would help if you can post a link to your page. |
|
Quote:
My banner images do not link correctly to the sites they are for. I am not familiar ith how to make a perl script. Also, where do I input the code to center the banners on the forum home page? Do I just use this code: <div style="text-align:center;"> <a href......>banner</a> </div> ??? Thanks for all of your help. I would really appreciate it if someone would help me so I can get this fixed. Thanks again! http://www.d-series.org/forums/? |
What code are you using to display the banner?
You just need to put a centre that. Ill help if you post the HTML which is displaying the banner. With regard to the perl script to make the link work, if you want to count the number of clicks of the banner then you need to use a perl script as the target of the banner. This is so you can count the number of times the perl script has been opened using a normal log file analysis program like Webtrends. The perl script should be located in your cgi-bin folder and you will need to make your banner link <A HREF= 'link to your perl script' target='_blank'> The link itself can be relative e.g.: '../cgi-bin/yourperlscript.pl' or direct 'htp://www.yoursite.com/cgi-bin/yourperscript.pl'. The first one is preferable. It looks like you haven't got the link location correct. The perl script will work if you put it in your cgi-bin folder and in telnet or with an appropriate ftp program chmod 755 yourperlscript.pl Presumably you have copied my example to create the correct perl script? Note : it's possible to have an alternative to using a perl script if you instead have the link fire up your own php application which counts the clicks for you. But you will need some programming and database experience to do this. |
Hi,Spinball
you typed for Ex: #!/usr/bin/perl print "Location: http://www.targetdomain.com/"; Can you make Ex with next info -> www.mylink.com alttext=MyLink and Ex for Forumhome,because I want to put the Banner above a navlink. Thanks again! |
You'll have to use one of the other hacks for banners above the navbar.
The perl script you quoted above is simply for couning the hits as explained in the description accompanying this thread. |
it will be a very nice hack but!
It only shows at forumdisplay.php when someone reads the thread showtread.php does not show the banner i have more than 100 forums and some categories is not possible to make this hack available for categories? or lets say how can i enable multiple forums like if ($forumid==76) { $mycustomheader = file_get_contents("http://domain.net/hosting.htm"); } // get external data do i have to copy and paste te code for multiple fourms or is there comma like code for multiple forums like if ($forumid==76,x,y,z) { i tried comma but doesnot work |
I have used my hack to display banners above and below threads.
Edit showthread.php and find ********************************************* // ################################################## ########################### // output page eval('print_output("' . fetch_template('SHOWTHREAD') . '");'); ********************************************* and add this code before it: ********************************************* $headerbanner = "<P ALIGN=\"CENTER\" CLASS=\"smallfont\">" . file_get_contents("http://www.url_of_your_script.php?forumid=$forumid&type=h eader") . "</P>"; $footerbanner = "<P ALIGN=\"CENTER\" CLASS=\"smallfont\">" . file_get_contents("http://www.url_of_your_script.php?forumid=$forumid&type=f ooter") . "</P>"; ********************************************* Then in the SHOWTHREAD template, find ********************************************* $navbar ********************************************* and after it, put ********************************************* <if condition="$headerbanner">$headerbanner</if> ********************************************* and find ********************************************* <if condition="$bbuserinfo[field11] == 'Yes'">$quickreply</if> ********************************************* and above it add ********************************************* <if condition="$footerbanner">$footerbanner</if> ********************************************* Then write your php script to output banners depending on what forumid is passed and whether it's the header or footer: PHP Code:
Re your specific code request, I recommend you learn some PHP. PHP Code:
Re displaying banners for whole categories, you might be able to do it, but I don't have time to look into it this year :) |
How would you do this if you want to include something on top of every page of the forum?
|
You wouldn't need to use this hack - use the phpinclude_start template instead.
|
Quote:
|
Do a search on vbulletin.com for phpinclude
|
Hi,
i am going to try, to use the shoutcast status Box, which is availible for vba-portal, on my Forumhome. When i try to include the shoutcast.php below the $navbar it says : Code:
Fatal error: Call to undefined function: fetch_template() in /srv/www/htdocs/web1/html/shoutcast.php on line 68 Code:
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_shoutcast') . '";'); th@nks |
try this, you're eval is a mess as is
PHP Code:
|
th@nks 4 reply, but i have still this error :
Code:
Fatal error: Call to undefined function: fetch_template() in /srv/www/htdocs/web1/html/shoutcast.php on line 68 here i paste the whole script : PHP Code:
i hade the eval twice, so i have tried also to change the eval below the server settings, but still not working. gr33tz |
you need to include the global.php :)
|
Quote:
Th@nks 4 help but i can't include that. if i use : require_once('./global.php'); into the Header of the php,Forumhome is going to open the shoutcast.php himself on the Index, and i cannot login anymore. gr33tz |
Sorry but is this relevant to the hack?
|
Also, where do I input the code to center the banners on the forum home page? Do I just use this code: <div style="text-align:center;">
<a href......>banner</a> </div> ??? PLEASE let me know as well! |
Well I use the phpinclude_start template:
Code:
ob_start(); Code:
$forum_heading |
After a couple of weeks of using this mod, and everything working OK, Today I logged to my forums, and I am getting the following error message at the top of FORUMHOME.
Warning: file_get_contents(): URL file-access is disabled in the server configuration in /index.php on line 59 Warning: file_get_contents(http://www.mydomain.com/forums/banners.php): failed to open stream: no suitable wrapper could be found in /index.php on line 59 |
Sounds like there has been some kind of configuration change.
If you access the URL in your browser rather than in the file_get_contents, does it work? |
Yes, it works.
|
The message
Quote:
If it worked previously, check (with your hosts) whether the configuration of the server has changed in some way. |
Quote:
PHP Code:
|
Adding to my post, above, re URL file-access is disabled in the server configuration:
I found this is because my server has the PHP option allow_url_fopen disabled, thus preventing accessing the file via http. For importing static html, the solution in the above post was fine. But one of my import files was a php file that generated some variable text depending on the date. When accessing this directly instead of as an http import, all I got was the static php code, not the RESULT of running the php code. The support folks at the server suggested using their installed cURL library in place of get_file_contents(). The following modification to this hack in forumdisplay.php is now working for me: PHP Code:
|
Quote:
It seams, this is not the case for my server. I see the text of the .php file, not the results of execution. What I should ask my host to change? |
All times are GMT. The time now is 04:43 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|