This is an old revision of the document!


Table of Contents

Bild als Link

FIXME translate

In der herkömmlichen Mediabox läßt sich lediglich Text optisch ansprechend als Link zur Funktion hinterlegen da dieser auch für die Bezeichnung innerhalb der Mediabox herangezogen wird. Verwendet man bspw. ein Bild wird dies ebenso als Caption eingebunden und zerreißt somit das Layout.

Mit dieser Erweitertung ist es möglich über einen Contentpart ein Bild zu definieren das als Link zur Mediabox-Funktion herhält und gleichzeitig einen Text als Caption innerhalb der Mediabox zu definieren.


Forum: http://forum.phpwcms.org/viewtopic.php?f=1&t=21080&p=132318#p132318

Autor: Robert Stein/ q23.media

Tag: siehe Beschreibung
Dateiname: mediaboxAdvanced_pimped.php
Verzeichnis: template/inc_script/frontend_render/disabled/ → nach: template/inc_script/frontend_render/

Bedingung:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;

Beschreibung

Basis TAG:
[MEDIABOX external|{IMAGE_HEIGHT} {IMAGE_WIDTH}|<img src=”{THUMB_REL}” height=”{THUMB_HEIGHT}” width=”{THUMB_WIDTH}”/>::[INFOHTML]{INFOHTML}[/INFOHTML]]{IMAGE_ABS}[/MEDIABOX]

Lege den TAG in einem CP-Template (Vorgabe für imagespecial) ab und dementsprechnd fein justieren. Anstelle des img-tags kann auch ein replacement-tag verwendet werden. Wichtig ist hierbei alles hinter ”::” da dies für die Caption gezogen wird. Ohne diesen Abtrenner wird wieder das Bild als Caption verwendet.

Code

mediaboxAdvanced_pimped.php

<?php
 
/**
* Wrapper Frontend Render Script for MediaBoxAdvanced
*
* Will replace MooTools 1.2 based Lightbox effect
* and handle [MEDIABOX] replacement tags.
*/
 
$mediaBox = array(
 
// set the CSS which should be used for mediaBox
// available by default: mediaboxAdvBlack.css, mediaboxAdvWhite.css
'css' => 'mediaboxAdvBlack21.css',
 
// default linktext
'linktext' => '@@More@@'
 
);
 
 
// check if current JS Lib is MooTools 1.2 otherwise it will not load
if(PHPWCMS_JSLIB != 'mootools-1.2' || ( strpos($content['all'], '[MEDIABOX') === false && strpos($content['all'], 'rel="lightbox') === false ) ) {
 
// remove all [MEDIABOX] replacement tags
$content['all'] = preg_replace( array('/\[MEDIABOX.*?\]/i', '/\[\/MEDIABOX\]/i'), '', $content['all'] );
 
} else {
 
// unset Slimbox CCC and JS
unset(
$block['custom_htmlhead']['lightbox.css'],
$block['custom_htmlhead']['slimbox.js']
);
 
// Set CSS color and/or More Text:
// <!-- MEDIABOX: black | @@More@@ -->
// <!-- MEDIABOX: white | @@More@@ -->
// <!-- MEDIABOX: myCustomMediaBox.css | @@More@@ -->
if(preg_match('/<!-- MEDIABOX:(.+?)-->/', $content['all'], $match)) {
 
$match = explode('|', trim($match[1]), 2);
$match[0] = trim($match[0]);
if($match[0] == 'black') {
$mediaBox['css'] = 'mediaboxAdvBlack21.css';
} elseif($match[0] != 'white') {
$mediaBox['css'] = $match[0];
} else {
$mediaBox['css'] = 'mediaboxAdvWhite21.css';
}
$match[1] = empty($match[1]) ? '' : trim($match[1]);
if($match[1]) {
$mediaBox['linktext'] = $match[1];
}
}
 
initJSLIb();
 
// load mediaBox JavaScript and CSS
set_css_link( 'lib/mediabox/css/'.$mediaBox['css'] );
initJSPlugin('Quickie-yui');
$block['custom_htmlhead']['mediabox.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mediabox/mediaboxAdv-yui.js');
$block['custom_htmlhead']['mediaboxvars.js'] = ' <script type="text/javascript">'.LF;
$block['custom_htmlhead']['mediaboxvars.js'] .= ' NonverBlasterPath="'.PHPWCMS_URL.TEMPLATE_PATH.'lib/nonverblaster/NonverBlaster.swf";'.LF;
$block['custom_htmlhead']['mediaboxvars.js'] .= ' JWPlayerPath="'.PHPWCMS_URL.TEMPLATE_PATH.'lib/jw_media_player/player.swf";'.LF;
$block['custom_htmlhead']['mediaboxvars.js'] .= ' </script>';
 
 
// parse and render MEDIABOX
$content['all'] = preg_replace_callback('/\[MEDIABOX(.*?)\](.*?)\[\/MEDIABOX\]/is', 'renderMediaBox', $content['all']);
 
}
 
function renderMediaBox($match) {
 
$types = array('twitter', 'social', 'flash', 'audio', 'inline', 'external', 'quicktime');
 
$set = trim($match[1]);
$inner = trim($match[2]);
 
$type = '';
$caption = '';
$url = '';
$linktext = '';
$html = '';
$size = '';
$lightbox = '';
 
// define type, size, caption - elements divided by pipe |
$set = explode('|', $set, 3);
foreach($set as $key => $item) {
 
$item = trim($item);
if($item == '') {
continue;
}
if($type == '' && in_array(strtolower($item), $types)) {
$type = strtolower($item);
continue;
}
if(!$size && preg_match('/^([0-9]+).([0-9]+)$/', $item, $s)) {
$size = intval($s[1]) . ' ' . intval($s[2]);
continue;
}
 
$caption = $item;
 
break;
}
 
// check inner elements - elements divided by pipe |
// it is formatted this way: url | linktext
$inner = explode('|', $inner, 2);
$inner[0] = trim($inner[0]);
$inner[1] = empty($inner[1]) ? '' : trim($inner[1]);
if($inner[1]) {
$linktext = $inner[1];
} elseif($caption) {
$linktext = explode('::', $caption);
$caption = trim($linktext[1]);
$linktext = trim($linktext[0]);
}
if($linktext == '') {
$linktext = $GLOBALS['mediaBox']['linktext'];
}
 
// test if first element is URL
if( preg_match('/^http|https:\/\//i', $inner[0]) ) {
$url = $inner[0];
}
 
// test against .flv, .mp3, .mp4, .aac, .m4a
if( preg_match('/(\.flv|\.mp3|\.mp4|\.m4a|\.aac|\.mov|\.m4v|\.aiff|\.avi|\.caf|\.dv|\.mid|\.m3u|\.mp2|\.qtz|\.f4v|\.f4p|\.f4a|\.f4b)$/i', $inner[0], $ext) ) {
 
$ext = strtolower($ext[1]);
$url = $inner[0];
 
// set type Flash (Video)
if($ext === '.flv' || $ext === '.mp4' || $ext === '.m4v') {
$type = 'flash';
} elseif($ext === '.mp3' || $ext === '.m4a' || $ext === '.aac' || $ext === '.f4a' || $ext === '.f4b') {
$type = 'audio';
} else {
$type = 'quicktime';
}
 
}
 
// what to do if URL is empty
if($url == '') {
$type = 'inline';
$html = $inner[0];
}
 
if($type != 'inline') {
 
if($type == 'audio' && $size == '') {
$size = '350 20';
}
 
$lightbox = '<a href="' . html_specialchars($url) . '" ';
$lightbox .= 'rel="lightbox[' . trim( $type . ' ' . $size ) . ']"';
$lightbox .= ' title="' . $caption . '"';
$lightbox .= '>' . $linktext . '</a>';
 
} else {
 
$id = 'mb_inline_' . generic_string(6, 1);
 
$lightbox = '<a href="#' . $id . '" ';
$lightbox .= 'rel="lightbox[' . trim( $type . ' ' . $size ) . ']"';
$lightbox .= ' title="' . html_specialchars( $caption ? $caption : $linktext2 ) . '"';
$lightbox .= '>' . $linktext . '</a>';
$lightbox .= LF . '<div id="' . $id . '" style="display:none;">';
$lightbox .= $html;
//$lightbox .= '<p><a href="#" onclick="Mediabox.close();return false;">@@close onClick@@</a></p>';
$lightbox .= '</div>';
 
}
 
return $lightbox;
 
}
 
?>


deutsch/ersetzer_rts/frontend_render/mediaboxadvanced/bild-als-link.1315569562.txt.gz · Last modified: 2018/06/03 18:07 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0