Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Long comments under thumbnails  (Read 14270 times)

0 Members and 1 Guest are viewing this topic.

pbasmo

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: fr
  • Offline Offline
  • Gender: Male
  • Posts: 133
    • Galerie de photos
Long comments under thumbnails
« on: June 28, 2007, 04:05:33 pm »

Hello

This article is the translation of french article here : http://forum.coppermine-gallery.net/index.php?topic=44532.0

I like to write comments to present the pictures and some comments are more or less long.
But during the display of the thumbnails, long comments disturb the display of the table and the visual aspect is not very homogeneous.
My idea was to limit the comments to 15 words by adding a message in other style to suggest that there is a continuation. To read the comment it is necessary to display the picture while clicking on the thumbnail.

2 scripts are modify :

1) style.css of the graphic theme :
I added this new entry :
Code: [Select]
.thumb_caption_suite {
color: #FFCC00;
font-weight: bold;
padding: 2px;
}
This code will display the message in other style.

2) script functions.inc.php
In the function build_caption, search these lines :
Code: [Select]
      if ($CONFIG['caption_in_thumbview']){
            $caption .= $row['caption'] ? "<span class=\"thumb_caption\">".strip_tags(bb_decode($row['caption']))."</span>" : '';
        }

and replace all by :

Code: [Select]
if ($CONFIG['caption_in_thumbview']){
   // ****************************************************************
   //MODIF du 18 juin 2007
   //Limitation à 15 mots des commentaire LONGS sous les vignettes

   // Initialisation du message de suite avec une fin de balise span
   // En cas d'absence de commentaire  la balise fermera la balise thumb_caption de mise en forme du comment.
   // En cas de commentaire, elle fermera les 2 balises de mises en forme du commentaire ET du message de suite.
   // Ceci pour afficher le message de suite juste apres le commentaire et éviter de générer 1 ligne supplémentaire
   $msg_suite = '</span>';

   // Si il y a un commentaire.....
   if ($row['caption'] != "") {
      // On définit le nbr de mots maxi à afficher
      $maxmots = 15;
      // Eclatement du commentaire en mots
      $mots = explode(" ",$row['caption'],$maxmots + 1);
      // On compte le nbre de mots trouvés
      $nbmots = count($mots);
      // On vide le reste du commentaire après le 15eme mot
      $mots[$maxmots] = "";
      // Si le nbr de mots trouvés -1 = le max autorisé, alors...
      if ($nbmots-1 == $maxmots) {
         // ... on fabrique le message de suite avec une balise de mise en forme définie dans le css..
         $msg_suite = '<span class="thumb_caption_suite">' . 'Suite...'.'</span>' ;
         // ... et on garde que le commentaire aurorisé en recomposant la phrase avec les mots séparés par 'espace'
         $row['caption'] = implode(" ",$mots);
      }
   }
   // Mise en forme du commentaire
   // La ligne initiale a été modifiée pour enlever la balise de fin /span
   $caption .= $row['caption'] ? "<span class=\"thumb_caption\">".strip_tags(bb_decode($row['caption'])) : '';
   // La balise de fin est ajoutée après le traitement du commentaire
   $caption = $caption . $msg_suite;
   // Fin de Modifications
   // ***********************************************************************
}

You can replace the word "Suite..." (in french) by other word or signs as ">>>"
You can see the result at http://pierre.basmoreau.free.fr/album/thumbnails.php?album=21 (or other albums)

Good day
Pierre
« Last Edit: June 29, 2007, 11:39:26 am by GauGau »
Logged

jesusarmy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 34
Re: Long comments under thumbnails
« Reply #1 on: December 18, 2007, 06:37:31 pm »

It should really be as below, with an extra </span> in the code.

Code: [Select]
if ($CONFIG['caption_in_thumbview']){
   // ****************************************************************
   //MODIF du 18 juin 2007
   //Limitation à 15 mots des commentaire LONGS sous les vignettes

   // Initialisation du message de suite avec une fin de balise span
   // En cas d'absence de commentaire  la balise fermera la balise thumb_caption de mise en forme du comment.
   // En cas de commentaire, elle fermera les 2 balises de mises en forme du commentaire ET du message de suite.
   // Ceci pour afficher le message de suite juste apres le commentaire et éviter de générer 1 ligne supplémentaire
   $msg_suite = '</span>';

   // Si il y a un commentaire.....
   if ($row['caption'] != "") {
      // On définit le nbr de mots maxi à afficher
      $maxmots = 15;
      // Eclatement du commentaire en mots
      $mots = explode(" ",$row['caption'],$maxmots + 1);
      // On compte le nbre de mots trouvés
      $nbmots = count($mots);
      // On vide le reste du commentaire après le 15eme mot
      $mots[$maxmots] = "";
      // Si le nbr de mots trouvés -1 = le max autorisé, alors...
      if ($nbmots-1 == $maxmots) {
         // ... on fabrique le message de suite avec une balise de mise en forme définie dans le css..
         $msg_suite = '<span class="thumb_caption_suite">' . 'Suite...'.'</span></span>' ;
         // ... et on garde que le commentaire aurorisé en recomposant la phrase avec les mots séparés par 'espace'
         $row['caption'] = implode(" ",$mots);
      }
   }
   // Mise en forme du commentaire
   // La ligne initiale a été modifiée pour enlever la balise de fin /span
   $caption .= $row['caption'] ? "<span class=\"thumb_caption\">".strip_tags(bb_decode($row['caption'])) : '';
   // La balise de fin est ajoutée après le traitement du commentaire
   $caption = $caption . $msg_suite;
   // Fin de Modifications
   // ***********************************************************************
}
Logged

Fabricio Ferrero

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 1996
  • From San Juan, Argentina, to the World!
    • http://fabricioferrero.com/
Re: Long comments under thumbnails
« Reply #2 on: March 17, 2008, 07:15:58 pm »

Where is it the fun "functions.inc.php" file? I can't find!

Thanks.
Logged
Read Docs and Search the Forum before posting. - Soporte en español
--*--
Fabricio Ferrero's Website

Catching up! :)

Nibbler

  • Guest
Re: Long comments under thumbnails
« Reply #3 on: March 17, 2008, 07:17:30 pm »

It's in the 'include' folder. Not hard to find.
Logged

mywedding

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 42
  • MyWedding
    • Wedding
Re: Long comments under thumbnails
« Reply #4 on: May 26, 2008, 10:51:16 pm »

i just start use this mod and i like it, this mod very useful , thx everybody :)

i use and love coppermine since 2002,
Logged
Dreams are free, so free your dreams, "Astrid Alauda"

dork313

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
    • NINart
Re: Long comments under thumbnails
« Reply #5 on: May 27, 2008, 04:35:37 am »

Great mod, thank you. Which line of code would one change to lower the amount to less than 15 words? Just curious to see what it looks like on my site.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Long comments under thumbnails
« Reply #6 on: May 27, 2008, 07:17:22 am »

Obviously
Code: [Select]
$maxmots = 15;-the only line that contains the number "15".
Logged

dork313

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
    • NINart
Re: Long comments under thumbnails
« Reply #7 on: May 27, 2008, 10:08:37 am »

Well, obviously,  that's what I assumed but when I lowered it I didn't see any changes so I thought no harm in asking. Thanks for the reply.
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 20 queries.