Hello All,
I have a drop down menu I am using on my web site. I also have a php script that grabs news from another website. Here is what I would like to accomplish:
When a user places their mouse over a word, such as Music, in the menu, it drops down another menu listing three links...MTV, Rolling Stone, and Spin.
Here is when the PHP comes in....PHP script grabs news headlines from each of these three sites. When the user places the mouse over MTV, instead of displaying more links, it would display the news grabbed with the PHP script and place it in a menu similar to the one displaying MTV, Rolling Stone, and Spin. Below is a copy of the code for the PHP script and the drop down menu I am using.
Is this task possible to accomplish? If so, could someone guide me setting this up? I already tried using <? include("pollstar_news.php"); ?> inplace of the HTML code in the drop down menu, but this just gave me errors.
Thanks for your help!
Drop Down Menu Script:
/UDMv2.1.1
//DO NOT EDIT THIS
if (!exclude) { //**
//*********************
// for more information about the script ************************
// see http://www.brothercake.com/dropdown/ ************************
// or http://www.dynamicdrive.com/dynamicindex1/topmen3/index.htm ****
// POSITIONING AND STYLES ******************************************
var menuALIGN = "center"; // alignment
var absLEFT = 0; // absolute left or right position (if not center)
var absTOP = 0; // absolute top position
var staticMENU = false; // static positioning mode (not Opera 5)
var stretchMENU = false; // show empty cells
var showBORDERS = false; // show empty cell borders
var baseHREF = ""; // base path to .js and image files
var zORDER = 100; // base z-order of nav structure (not ns4)
var mCOLOR = "0D0E30"; // main nav cell color
var rCOLOR = "cococo"; // main nav cell rollover color
var keepLIT = true; // keep rollover color when browsing menu
var bSIZE = 1; // main nav border size
var bCOLOR = "0D0E30" // main nav border color
var aLINK = "FFFFFF"; // main nav link color
var aHOVER = ""; // main nav link hover-color (not ns4)
var aDEC = "none"; // main nav link decoration
var fFONT = "arial"; // main nav font face
var fSIZE = 13; // main nav font size (pixels)
var fWEIGHT = "bold" // main nav font weight
var tINDENT = 7; // main nav text indent (if text is left or right aligned)
var vPADDING = 5; // main nav vertical cell padding
var vtOFFSET = 0; // main nav vertical text offset (+/- pixels from middle)
var vOFFSET = -5; // shift the submenus vertically
var hOFFSET = 4; // shift the submenus horizontally
var smCOLOR = "e8e8e8"; // submenu cell color
var srCOLOR = "cococo"; // submenu cell rollover color
var sbSIZE = 1; // submenu border size
var sbCOLOR = "cococo" // submenu border color
var saLINK = "cococo"; // submenu link color
var saHOVER = ""; // submenu link hover-color (not ns4)
var saDEC = "none"; // submenu link decoration
var sfFONT = "arial";// submenu font face
var sfSIZE = 13; // submenu font size (pixels)
var sfWEIGHT = "normal" // submenu font weight
var stINDENT = 5; // submenu text indent (if text is left or right aligned)
var svPADDING = 2; // submenu vertical cell padding
var svtOFFSET = 0; // submenu vertical text offset (+/- pixels from middle)
var shSIZE = 2; // submenu drop shadow size
var shCOLOR = "#cccccc"; // submenu drop shadow color
var shOPACITY = 45; // submenu drop shadow opacity (not ns4 or Opera 5)
// LINKS *********************************************************
// add main link item ("url","Link name",width,"text-alignment","target")
addMainItem("products.html","Technology",80,"center","_self");
defineSubmenuProperties(120,"right","left");
addSubmenuItem("product1.html","Pollstar","_self");
addSubmenuItem("product2.html","Product 2","_self");
addSubmenuItem("product3.html","Product 3","_self");
addSubmenuItem("product4.html","Product 4","_self");
addMainItem("services.html","Music",80,"center","_self");
defineSubmenuProperties(120,"left","left");
addSubmenuItem("service1.html","Service 1","_self");
addSubmenuItem("service2.html","Service 2","_self");
addSubmenuItem("service3.html","Service 3","_self");
addMainItem("news.html","News",60,"center","_self");
defineSubmenuProperties(120,"right","right");
addSubmenuItem("article1.html","Article 1","_self");
addSubmenuItem("article2.html","Article 2","_self");
addSubmenuItem("article3.html","Article 3","_self");
addSubmenuItem("article4.html","Article 4","_self");
addMainItem("contact.html","Outside",80,"center","_self");
defineSubmenuProperties(120,"left","left");
addSubmenuItem("customerservice.html","Customer Service","_self");
addSubmenuItem("faq.html","FAQ","_self");
addSubmenuItem("troubleshooting.html","Troubleshooting","_self");
//********************************************************************
//DO NOT EDIT THIS
}//*****************
//*********************
PHP Script:
<?php
$startingpoint = "<td width='*'>"; // replace inside the quotes with with your unique start point in the source of the HTML page. It HAS to be unique.
$endingpoint = "</a></font><br><br>"; // replace with the unique finish point in the source of the HTML page
//Don't forget to escape any " marks with a \ mark.
// Example: If the starting HTML is: <img src="images/something.jpg">
// You would tell Mini-Fetch: $startingpoint = "<img src=\"images/something.jpg\">";
//That's probably all you need to edit, unless you want to match and replace certain text or HTML.
// - "Don't touch this part..."
preg_match("/(https?:\/\/)?([\/])(.)/i", "$theLocation", $matches);
$theDomain = "http://" . $matches[2];
$page = $matches[3];
$fd = fopen($theDomain.$page, "r"); // can change to "rb", on NT/2000 servers, if problems.
$value = "";
while(!feof($fd)){
$value .= fread($fd, 4096);
}
fclose($fd);
$start= strpos($value, "$startingpoint");
$finish= strpos($value, "$endingpoint");
$length= $finish-$start;
$value=substr($value, $start, $length);
// end "don't touch this part"
// eregi_replace, below, is a case-insensitive function to find, match, and replace variations of text that you define.
//The following commands strip or replace HTML tags.
//To NOT strip a certain HTML tag, add // before the line in question.
// the "", before the $value at the end of the line means replace the tag with blank space, which effectively deletes the tag.
//$value = eregi_replace( "<img src=[>]>", "", $value ); // Remove all image tags. This is disabled until you remove the // in front of this line.
$value = eregi_replace( "<IMG alt=[>]>", "", $value ); // Remove all image alt="whatever" tags
$value = eregi_replace( "<class[>]>", "", $value ); // Remove all variations of <class> tags.
$value = eregi_replace( "<table[>]>", "", $value ); // Remove ALL variations of <table> tags.
$value = eregi_replace( "<tr[>]>", "", $value ); // Replace <tr> tags with blank space.
$value = eregi_replace( "<td[>]>", "", $value ); // Remove all variations of <td> tags.
// Below - what's the difference, you ask, between eregi_replace and str_replace?
// str_replace is faster, by a long shot... The catch is that in can only be used
// to replace EXACT value matches, as you see below, and doesn't work well in huge files without using arrays.
$value = str_replace( "</font>", "", $value ); // Remove closing </font> tags.
$value = str_replace( "</table>", "", $value ); // Remove closing </table> tags.
$value = str_replace( "</tr>", "", $value ); // Remove closing </tr> tags.
$value = str_replace( "</td>", "", $value ); // Remove closing </td> tags.
$value = str_replace( "<center>", "", $value ); // Remove <center> tag...
$value = str_replace( "</center>", "", $value ); // ...alignment calls.
$value = str_replace( "<b>", "", $value ); // Remove <b> tags.
$value = str_replace( "</b>", "", $value ); // Remove closing </b> tags...
// More tags. Just take out the // in front and edit as you like.
$value = eregi_replace( "Copyright 2002 Pollstar.", "", $value ); // Remove certain text...
$value = eregi_replace( "Forums", "", $value ); // Remove certain text...
$value = eregi_replace( "Home", "", $value ); // Remove certain text...
$value = eregi_replace( "Store", "", $value ); // Remove certain text...
$value = eregi_replace( "Marketplace", "", $value ); // Remove certain text...
$value = eregi_replace( "Notify", "", $value ); // Remove certain text...
$value = eregi_replace( "Premium", "", $value ); // Remove certain text...
$value = eregi_replace( "All Rights Reserved", "", $value ); // Remove certain text...
//$value = eregi_replace( "<javascript[>]>", "", $value ); //remove javascripts
//$value = eregi_replace( "<script[>]>", "", $value ); //remove scripts
// replace normal links with HTML to open fetched links in new window
$value = eregi_replace( "href=", "target=\"_blank\" href=", $value );
// open links that use " in new window
$value = eregi_replace( "href=\"", "target=\"_blank\" href=\"", $value );
$FinalOutput = preg_replace("/(href=\"?)(\/[\"\/]+)/", "\1" . $theDomain . "\2", $value);
echo $FinalOutput; //prints it to your page
// Next line not mandatory! To disable it, either delete it or add // in front of it.
//echo "<a href=\"http://www.mikenew.net\"><img src=\"http://www.mikenew.net/images/php.gif\" alt=\"web site content, automatic updates\" width=\"20\" height=\"20\" border=\"0\"></a>";
flush (); //force output to your page faster
?>