vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Insert HTML or (pre-processed!) PHP file above specific forum (https://vborg.vbsupport.ru/showthread.php?t=67942)

Spinball 08-02-2004 10:00 PM

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?

Spinball 08-03-2004 08:22 AM

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:

<?php
$banners 
= array (
        
"banner1.gif|link1.pl|Alt text for banner 1|0|468|60",
        
"banner2.gif|link2.pl|Alt text for banner 2|0|468|60",
        
"banner3.gif|link3.pl|Alt text for banner 3|0|468|60",
        
"banner4.gif|link4.pl|Alt text for banner 4|0|468|60"
);
$banner $banners[mt_rand(0,sizeof($banners) - 1)];
list(
$imgsrc,$myurl,$alttext,$border,$width,$height) = explode ('|',$banner);
echo(
"<A HREF=\"http://www.yourdomain.com/cgi-bin/$myurl\" TARGET = \"_blank\"><IMG src=\"http://www.yourdomain.com/adverts/banners/$imgsrc?" mt_rand(1,999) . "\" border=\"$border\" width=\"$width\" height = \"$height\" alt=\"$alttext\"></A>");
?>

Notes:
  1. banner1.gif to banner4.gif are the names of the banner files
  2. the banner files exist in the /adverts/banners/ folder on your website (change this to whatever you want)
  3. link1.pl to link4.pl are simple perl scripts which open up the target websites (see below)
  4. the perl scripts are in your cgi-bin folder
  5. the 0|468|60 are the border width (0=no border), banner width and banner height for each banner. Mine are all the same - no border and 468x60.
  6. using _blank for the target makes the new websites open in a new window. Remove the TARGET = \"_blank\" bit if you want it to open in the same window

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
print "Location: http://www.targetdomain.com/";

Oh and adding
PHP Code:

mt_rand(1,999

on to the end of the name of the image helps ensure that people's cache doesn't open up old versions of banners.
--------------------------------------------------------------------------------------------------
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 :)

jluerken 08-03-2004 10:20 AM

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.

Spinball 08-03-2004 10:49 AM

Yes it will.
Instructions added into the text file August 7 2004.

msu 08-05-2004 09:16 PM

thanx for this cool hack , and it will be great if you make it for vbulletin 2.x.x people

:)

Spinball 08-07-2004 08:38 PM

Quote:

Originally Posted by msu
thanx for this cool hack , and it will be great if you make it for vbulletin 2.x.x people

:)

This will work with vB2, you'll just need to find the right places to put the php code and which template to edit and where within that template.
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.

msu 08-07-2004 09:07 PM

thank you again :)

hukgwai 08-08-2004 02:38 PM

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?

Spinball 08-08-2004 03:05 PM

Quote:

Originally Posted by hukgwai

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?

Yeah - you're right - I've updated it, thanks.
Is this the source of your error?
If not what is the line at 372 in your file?

xxxGiJoe 08-13-2004 02:35 PM

Works GREAT!!!

http://wolfgaming.net/wgn/vB/forumdisplay.php?f=161


All times are GMT. The time now is 11:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01156 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete