{TOOLTIP:name:tip}
Posted: Sun 16. Oct 2005, 12:39
I had a need to create a {TOOLTIP} replacement tag so I thought I'd share it..
First: the styles: add this style to your phpwcms_template/inc_css/frontend.css file & edit at will
Next: the replacement tag:
This code goes in whichever file you use for custom replacement rats (in phpwcms_template/inc_script/frontend_render/mytags.php)
REMEMBER!! replace the 'n' in both lines of the tag to the next number in the list of existing tags - use the same number for both.
If you don't have a custom tags file then create one within phpwcms_template/inc_script/frontend_render/myTags.php and use the code below...
what are the uses?
I have listed some useages for this {RT} below
the uses are various but I use it to display 'helpfull hints' under words and images of question marks or in forms to explain what the error.gif means.
have fun.
First: the styles: add this style to your phpwcms_template/inc_css/frontend.css file & edit at will
Code: Select all
/* TOOLTIPS STYLE*/
.tooltip{
position:relative;
z-index:24; background-color:#fff;
color:#000;
text-decoration:none}
.tooltip:hover{z-index:25; background-color:#FFFFFF}
.tooltip span{display: none}
.tooltip:hover span{ /*the span will display just on :hover state*/
display:block;
position:absolute;
top:0em; left:1.5em; width:15em;
border:1px solid #EEEEEE;
background-color:#FFFF00; color:#000000;
text-align: center}
This code goes in whichever file you use for custom replacement rats (in phpwcms_template/inc_script/frontend_render/mytags.php)
Code: Select all
// tooltip {RT} | useage: {TOOLTIP:name,tip}
$search[n] = '/\{TOOLTIP:(.*?),(.*?)}/';
$replace[n] = '<a class="tooltip" href="#">$1<span>$2</span></a>';
If you don't have a custom tags file then create one within phpwcms_template/inc_script/frontend_render/myTags.php and use the code below...
Code: Select all
<?
// parse the $string and replace all possible instances of the following {RT}'s
function myTagParser($string) {
$search[0] = '/\{TOOLTIP:(.*?),(.*?)}/';
$replace[0] = '<a class="tooltip" href="#">$1<span>$2</span></a>';
$string = preg_replace($search, $replace, $string);
//remove all the *'s in the following two lines - they are there because phpbb will not show the code correctly :(
$string = str_replace('\*;'*;', ''*;', $string);
$string = str_replace('&*;quot*;', '& quot*;', $string);
return $string; // spit out the final webpage for display
}
// parse the whole webpage $content["all"] is the fully rendered webpage your site displays
$content["all"] = (myTagParser ($content["all"]));
?>
what are the uses?
I have listed some useages for this {RT} below
the uses are various but I use it to display 'helpfull hints' under words and images of question marks or in forms to explain what the error.gif means.
- {TOOLTIP:this is my tip for you,don't be nosey!}
- {TOOLTIP:<img src="./path/to/img1.gif">,don't be nosey!}
- {TOOLTIP:<img src="./path/to/img1.gif">,<img src="./path/to/img2.gif">}
have fun.