
$Item->content();
With
$mymessagecontent = $Item->content();
$triggerstring = "The string you want to trigger start of box";>
$endtriggerstring = "The string you want to end the box";
$boxtriggerstring = "The string you want to start the text to hoover over to display the box";
$endboxtriggerstring = "The text to end hoover text";
if(strpos($mymessagecontent, $triggerstring) != 0) {
include("insert_menu.php");
}
echo $mymessagecontent;
I have added the code to display the box in a separate file called insert_menu.php. This file looks like this:
$textpos = 0;
$characters_on_one_line = 50;
$tempmessage = $mymessagecontent;
while($textpos (bigger than) strlen($mymessagecontent) AND strpos($tempmessage, $triggerstring) != 0) {
$startpos = strpos($tempmessage, $boxtriggerstring);
$endpos = strpos($tempmessage, $endboxtriggerstring);
$mylinkstring = substr($tempmessage, $startpos+strlen($boxtriggerstring), $endpos-($startpos+strlen($boxtriggerstring)));
$tempmessage = substr($tempmessage, $textpos, $endpos-(strlen($mylinkstring)+strlen($boxtriggerstring))).substr($tempmessage, $endpos+strlen($endboxtriggerstring));
$startpos = strpos($tempmessage, $triggerstring);
$endpos = strpos($tempmessage, $endtriggerstring);
$myboxcontent = substr($tempmessage, $startpos+strlen($triggerstring), $endpos-($startpos+strlen($triggerstring)));
$myboxcontent= unhtmlentities($myboxcontent);
$myboxcontent = wordwrap($myboxcontent, $characters_on_one_line, "
");
$tempmessage = substr($tempmessage, $textpos, $startpos)."javascript text to open the box".$mylinkstring."".substr($tempmessage, $endpos+strlen($endtriggerstring));ADD THE CODE TO DISPLAY THE BOX
}
$mymessagecontent = $tempmessage;
The function unhtmlentities looks like this (I use it to get correct wrapping in the box). I have added it to _functions.php
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$ret = strtr ($string, $trans_tbl);
return preg_replace('/\&\#([0-9]+)\;/me',
"chr('\\1')",$ret);
}
The code to display the boxes will of course depend on the solution you choose. For those of you having access to SOTHINK DHML MENU, and can't get it to work properly, contact me here and I'll send you the complete code.