Page 1 of 1

Nur ein Vorschaubild in CP Bilder spezial

Posted: Tue 29. Dec 2009, 10:03
by Marcel
Hallo

Ich möchte im CP Bilder spezial nur vom ersten Bild eine Vorschau anzeigen lassen. Default werden ja alle Bilder als Vorschau angezeigt. Habe versucht ab dem zweiten Bild einfach kein Vorschaubild mehr anzugeben, dann funktioniert aber die Slide-Show (next/prev) nicht – kann mir jemand helfen?

Danke
mm

Re: Nur ein Vorschaubild in CP Bilder spezial

Posted: Wed 30. Dec 2009, 09:39
by flip-flop
Hallo,

ich könnte mir das ungefähr so vorstellen ohne groß herumzubasteln:

- Du legst einfach alle Thumbs übereinander (positon: absolute)
- Nun feht noch ein Index (z-index), damit wirklich das erste Thumb oben liegt.
- Dazu kann ein kleiner CP-Trigger verwendet werden.

Beispiel:
Template:

Code: Select all

<!--IMAGES_HEADER_START//-->
<!-- ImagesSpecial01 //-->
...
...
<!--IMAGES_HEADER_END//-->

<!--IMAGES_ENTRY_START//-->
	<div style="z-index:55{IMGID}; position: absolute;" class="imageEntry" id="img{IMGID}">
		{IMAGE}
	</div>
<!--IMAGES_ENTRY_END//--> 
Das <!-- ImagesSpecial01 //--> im Template Kopf dient nur dazu, um wirklich das richtige Template zu erwischen und nicht zufälligerweise auch bei anderen Image special Templates etwas zu tauschen.


Trigger: /template/inc_script/frontend_init/cp_trig_images_special.php

Code: Select all

<?php
 
// http://forum.phpwcms.org/viewtopic.php?p=107107#p107107
/* ------------------------------------------------------------------
function cp_trigger_function_name($param1, & $param2) {
   if($param2['acontent_type'] == 14) { // 14 is CP WYSIWYG
      $param1 = do_this_or_that($param2['acontent_id']);
   }
   return $param1;
}
 
* cp_trigger_function_name - the unique function name
* $param1 - holds the content part html source on which you can parse or do custom processing
* $param2 - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent
 
Always return $param1;
*/
// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------

/* Sucht im CP Image Special nach z-index:550 und ersetzt durch z-index:999 */ 
 
function CP_IMAGES_SPECIAL($text, & $data) {

   if( ($data['acontent_type'] == 31) AND                        // 31 is CP imgagesspecial
       (strpos($text, '<!-- ImagesSpecial01 //-->') != false) )   // Ist es das richtige Template?
   { 
         $text = str_replace('z-index:550','z-index:999', $text);
   }

   return $text;
}

register_cp_trigger('CP_IMAGES_SPECIAL');

?>
Sollte funktionieren.

Knut

Re: Nur ein Vorschaubild in CP Bilder spezial

Posted: Wed 30. Dec 2009, 12:56
by Marcel
Hey Knut – danke für die Mühe - funktioniert annähernd perfekt. Das einzige Problem ist, dass sich der ganze CP jetzt über den folgenden CP legt. Kann ich das irgendwie über eine CSS Anweisung regeln?
mm

Re: Nur ein Vorschaubild in CP Bilder spezial

Posted: Wed 30. Dec 2009, 13:47
by flip-flop
Das ist doch klar, wenn position:absolute; verwendet wird.
Um das zu umgehen kannst du einen Container mit definierter Höhe drumherum legen.

Kopf-und Fußteil des Templates bilden hier den umschließenden Container, der die Höhe von den Thumbs bezieht.

Code: Select all

....
....
<div style="height:{THUMB_HEIGHT_MAX}px;" .......>
<!--IMAGES_HEADER_END//-->
...
...
<!--IMAGES_FOOTER_START//-->
</div>
....
...

Hier eine andere Variante die mit display:none; arbeitet, also dieses Problem ausschließt. Läuft jedoch einen Tick langsamer, trotz optimierung
(function str_replace_once(.... ):

Template:

Code: Select all

<!--IMAGES_HEADER_START//-->
<!-- ImagesSpecial01 //-->
...
...
<!--IMAGES_HEADER_END//-->

<!--IMAGES_ENTRY_START//-->
   <!-- <div style="z-index:55{ IMGID}; position: absolute;" class="imageEntry" id="img{ IMGID}"> //-->
   <div style="display:none;" id="img{IMGID}"; class="imageEntry">
      {IMAGE}
   </div>
<!--IMAGES_ENTRY_END//-->

Trigger: /template/inc_script/frontend_init/cp_trig_images_special.php

Code: Select all

<?php
 
// http://forum.phpwcms.org/viewtopic.php?p=107107#p107107
/* ------------------------------------------------------------------
function cp_trigger_function_name($param1, & $param2) {
   if($param2['acontent_type'] == 14) { // 14 is CP WYSIWYG
      $param1 = do_this_or_that($param2['acontent_id']);
   }
   return $param1;
}
 
* cp_trigger_function_name - the unique function name
* $param1 - holds the content part html source on which you can parse or do custom processing
* $param2 - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent
* 
 * Always return $param1;
*/
// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------

/** 
 * 
 * KH: 30.12.09
 * Sucht im CP Images Special nach  %%style="display:none;" id="img0%% 
 * und erstzt durch  %%style="display:block;" id="img0%%
 * 
 *Verwendet wird hier eine Laufzeitoptimierte Version, die str_replace mit einer Funktion verwendet 
 *anstatt preg_replace 
 * ':none;" id="img0' -> ':block;" id="img0' 
 */




/* Only the first occurence is replaced ----------- */
function str_replace_once($needle , $replace , $haystack){
    // Looks for the first occurence of $needle in $haystack
    // and replaces it with $replace.
    $pos = strpos($haystack, $needle);
    if ($pos === false) {
        // Nothing found
    return $haystack;
    }
    return substr_replace($haystack, $replace, $pos, strlen($needle));
} 




// V1: Sucht im CP Image Special nach 'z-index:550' und ersetzt durch 'z-index:999' 
// V2: Sucht im CP Image Special nach 'style="display:none;" id="img0' 
//                    und ersetzt mit 'style="display:block;" id="img0'
// --------------------------------------------------------------------------------

function CP_IMAGES_SPECIAL($text, & $data) {

  if( ($data['acontent_type'] == 31) AND                         // 31 is CP imgagesspecial
      (strpos($text, '<!-- ImagesSpecial01 //-->') != false) )   // Ist es das richtige Template?
  { 
//      $text = str_replace('z-index:550','z-index:999', $text);
//      $text = preg_replace('/:none;" id="img0/',':block;" id="img0', $text,1);
        $text = str_replace_once(':none;" id="img0' , ':block;" id="img0' , $text);
  }

  return $text;

}

register_cp_trigger('CP_IMAGES_SPECIAL');

?>
[EDIT]
Ein Thumb - mehrere Großansichten: http://www.phpwcms-howto.de/wiki/doku.p ... zansichten
[/EDIT]

Knut

Re: Nur ein Vorschaubild in CP Bilder spezial

Posted: Thu 31. Dec 2009, 10:08
by Marcel
Super, danke Dir – und guten Rutsch.
Marcel