This RT returns a text link to a picture, this is then shown in a lightbox/slimbox.
Just put this in a *.php file in frontend_render folder.
Code: Select all
<?php
// ****************************************************************
// Tue Feb 19, 2008 Heiko H.
// http://forum.phpwcms.org/viewtopic.php?p=99630#p99630
//
// This RT returns a text link to a picture,
// this is then shown in a lightbox/slimbox.
//
// Just put this in a *.php file in frontend_render folder.
//
// Use the RT like this
// [LIGHTBOX:real_imagename.ext:Your Caption]Your Text[/LIGHTBOX]
// The real imagename (eg. image.jpg) can be found in file center.
// ****************************************************************
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
function lightbox_link($real_imgname, $caption, $link_text="")
{
//hash+ext des files ermitteln
$sql = "SELECT f_hash, f_ext "."FROM ".DB_PREPEND."phpwcms_file WHERE f_name LIKE '".$real_imgname."' AND f_trash = '0'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
$img_hash = $row[0];
$img_ext = $row[1];
//link zusammenstellen
$lightbox_link = "<a href=\"".PHPWCMS_FILES.$img_hash.".".$img_ext."\" class=\"lightbox_link\" rel=\"lightbox\" title=\"".$caption."\" target=\"_blank\">";
$lightbox_link .= $link_text."</a>";
//link ausgeben
return $lightbox_link;
}
if( ! ( strpos($content["all"],'[LIGHTBOX:')===false ) )
{
//Prüfung ob slimbox.css usw. schon vorhanden
if (!isset ($GLOBALS['block']['custom_htmlhead']['lightbox.css']))
{
$GLOBALS['block']['custom_htmlhead']['lightbox.css'] = ' <link rel="stylesheet" href="'.TEMPLATE_PATH.'slimbox/css/slimbox.css" type="text/css" media="screen" />';
}
if (!isset ($GLOBALS['block']['custom_htmlhead']['mootools.js']))
{
$GLOBALS['block']['custom_htmlhead']['mootools.js'] = ' <script src="'.TEMPLATE_PATH.'inc_js/mootools/mootools.js" type="text/javascript"></script>';
}
if (!isset ($GLOBALS['block']['custom_htmlhead']['slimbox.js']))
{
$GLOBALS['block']['custom_htmlhead']['slimbox.js'] = ' <script src="'.TEMPLATE_PATH.'slimbox/js/slimbox.js" type="text/javascript"></script>';
}
$content['all'] = preg_replace('/\[LIGHTBOX:(.*?):(.*?)\](.*?)\[\/LIGHTBOX]/e','lightbox_link("$1","$2","$3");',$content['all']);
}
?>
The real imagename (eg. image.jpg) can be found in file center.
I know ist's not perfect, feel free to use it, change it to your needs, or what ever...
[EDIT]
I Changed the code now the original uploaded image is shown in Lightbox and you can add a caption-text.
CSS Class added .lightbox_link
[/EDIT]
Greets Heiko...