Lightbox parse error in 1.2.8

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
beat
Posts: 99
Joined: Wed 23. Nov 2005, 15:18
Location: Gerzensee
Contact:

Lightbox parse error in 1.2.8

Post by beat »

Hi Folks
I've copied the code into a php file called lightbox.php.

Ive adjusted conf.template_default.inc.php

but as soon as I place lightbox.php into frontend-render I get this

Parse error: parse error, unexpected T_STRING in /home/sites/site137/web/cms/phpwcms_template/inc_script/frontend_render/lightbox.php on line 17

I'll try to use lightbox here http://www.loewen-worb.ch/cms

maybe someone has a good Idea
thanks
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

hi, please post your question in the right thread ;-)
http://www.phpwcms.de/forum/viewtopic.php?t=12950

you should check line 17 of lightbox script, maybe you forget a ; or " or $ while change the values?!

take a look on it it should look like this:

$var="value";

greetings marcus
beat
Posts: 99
Joined: Wed 23. Nov 2005, 15:18
Location: Gerzensee
Contact:

Post by beat »

Hi Marcus

I've got the front-render script from Pepe, what did work well. There is one mainproblem, when I want to use the caption, I get 2 title atttributes written into the code, which is of course not valid.

I guess my problem was the formating of the .php file.

But I will keep trying.

Thanks a lot, its a great script!
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

beat wrote:Hi Marcus

I've got the front-render script from Pepe, what did work well. There is one mainproblem, when I want to use the caption, I get 2 title atttributes written into the code, which is of course not valid.

I guess my problem was the formating of the .php file.

But I will keep trying.

Thanks a lot, its a great script!
mmmh, post the script if needed and i could take a look...
beat
Posts: 99
Joined: Wed 23. Nov 2005, 15:18
Location: Gerzensee
Contact:

Post by beat »

Oh Tanks a lot, thats actually really great.

Code: Select all

<?php 

// MAKE LIGHTBOX GALLERY v0.2.1. 
// m.o. 13.11.2006 
// modified by Manfred Peperkorn 28.11.2006

// set these to the right class you have given in 
// config/phpwcms/conf.template_default.inc.php
//
// $template_default["article"]["imagelist_class"]
// $template_default["article"]["imagelist_caption_class"]
// $template_default["article"]["imagelist_table_class"]
/*
Die folgenden 5 Zeilen in den Bereich "html-Head" des templates kopieren

<!-- lightbox 2.02 neu -->
<script type="text/javascript" src="include/inc_js/lightbox/prototype.js"></script>
<script type="text/javascript" src="include/inc_js/lightbox/scriptaculous.js?load=effects"></script> 
<script type="text/javascript" src="include/inc_js/lightbox/lightbox.js"></script>
<link rel="stylesheet" href="include/inc_css/lightbox.css" type="text/css" media="screen" />

*/


$imagecpclass = "imagegallery"; 
$imagecellclass = "imagelisttd"; 
$imagecaptclass = "imglistcaption"; 

// change the following only if required! 

function makelightbox($img,$thumb,$caption="",$pos="gallery_0") { 
$img = base64_decode($img); 
$thumb = stripslashes($thumb); // holds the pure orginal htmlcode for displaying the thumbimage 
//$caption = convert_to_anything($caption); // maybe you need to check the caption for something illegal  
list($img, $width_height) = explode('?', $img); 
$img = $GLOBALS["phpwcms"]["content_path"]."images/".$img; // this is the full picturepath 
// if you want to use an other presentation methode or an other script you can change the linkage here. 

// echo '<br />Bildunterschrift: '.$caption . '<br /><br />';

// preg_match('#alt="(.*)"#',$thumb,$alttext); 
preg_match('#alt="(.*)"#',$thumb,$alttext); 
$caption = $alttext[1]; // overwrite the caption var with phpWCMS-alttext

$search = '="';
//$captionPart2 = stristr($caption,$search);
//$caption = $captionPart2;
//$caption = strtr($caption,'="',' ');

//echo 'Titel: ' .$caption . '<br /><br />';

//$image ="<a href=\"".$img."\" rel=\"lightbox[".$pos."]\" title=\"".$caption."\">".$thumb."</a>"; 
$image ='<a href="'.$img.'" rel="lightbox['.$pos.']" title="'.$caption.'">'.$thumb.'</a>'; 
return $image; 
} 

// first search for given css class "imagecpclass" to separate each gallery-table 
$searchcp ='#<table.*[^>]class="'.$imagecpclass.'">(.*)<\/table>#Us'; // U = ungreedy 
preg_match_all($searchcp,$content["all"],$matchcp, PREG_PATTERN_ORDER); 

// if found one or more picture tables loop through then and replace for each. 
foreach($matchcp[0] as $mypos => $piccp) { 
$pos = "gallery_".$mypos; // this give unique names for the gallery slideshow. 

// search for "imagelisttd" which describe the image table 
$search ='#<td class="'.$imagecellclass.'">(.*)<\/td>#U'; // U = ungreedy 
preg_match_all($search,$matchcp[0][$mypos],$match, PREG_PATTERN_ORDER); 
//print_r($match); 

// search for "imglistcaption" class to grab the caption 
$searchcapt ='#<td class="'.$imagecaptclass.'">(.*)<\/td>#U'; // U = ungreedy 
preg_match_all($searchcapt,$matchcp[0][$mypos],$matchcapt, PREG_PATTERN_ORDER); 


if(is_array($match[1])) { 
// now loop through the matches and replace them with the custom code from function makelightbox() 
foreach($match[1] as $i => $imgcell) { 
$caption=$matchcapt[1][$i]; // get image caption if available - if not, it's empty 
$linkfind ='#<a href="image_zoom.php\?show=(.*)".*[^>]>(.*)</a>#Ue'; 
$linkreplacer ="makelightbox('$1','$2','$caption','$pos')"; 
$replace = preg_replace($linkfind,$linkreplacer,$match[1][$i]);
// last thing is replace the exact strings with the new one 
$content["all"] = str_replace($match[1][$i], $replace, $content["all"]); 
} 
} 
} 
?>
This is the script[/quote]
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

mmh, I drop this script in my installation, and it does what it should do.
It use the alt text of the image and put it into the title, of the enclosed link.

no problems here, and no double values?!
have you got an example page?

best m.
beat
Posts: 99
Joined: Wed 23. Nov 2005, 15:18
Location: Gerzensee
Contact:

Post by beat »

yes here

http://www.loewen-worb.ch/cms/index.php?zimmer

this is the error I get

Code: Select all

... dropping value "..." for repeated attribute "..."
have a look at the source
pepe
Posts: 3954
Joined: Mon 19. Jan 2004, 13:46

Post by pepe »

Hi beat,

using "my" modified script of markus, it makes the following code:
<class="imagegallery">
<td class="imagelisttd">
<a href="content/images/655xxx.jpg" rel="lightbox[gallery_1]" title=" Klosterkirche">
<img src="content/images/009xxx.jpg" width="164" height="123" border="0" class="imagelistimg" alt="Klosterkirche" title="Klosterkirche" /></a></td>
</div>
And so it's OK, i hope????.... for me, it works well.....

Don't know, if the 2 spacers behind the starting " produce the Problem????


But try the following "original" codelines again!
preg_match('#alt="(.*)"#',$thumb,$alttext);
$caption = $alttext[1]; // overwrite the caption var with phpWCMS-alttext

$search = '="';
$captionPart2 = stristr($caption,$search);
$caption = $captionPart2;
$caption = strtr($caption,'="',' ');

$image ='<a href="'.$img.'" rel="lightbox['.$pos.']" title="'.$caption.'">'.$thumb.'</a>';
return $image;
}
Post Reply