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: addendum to "thumb_title - viewed" output  (Read 3936 times)

0 Members and 1 Guest are viewing this topic.

eke

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
addendum to "thumb_title - viewed" output
« on: November 29, 2003, 03:22:08 pm »

file: functions.inc.php
code change: how the thumb_title and the n_views are rendered
css: class .thumb_title / new: .n_views

#449: the thumb_title line checks for "title" and "hits" and hence the span line always gets rendered (except for images that have not yet been viewed once).

#449:
Code: [Select]

                        $caption = ($rowset[$key]['title']||$rowset[$key]['hits']) ? "<span class=\"thumb_title\">".$rowset[$key]['title'].(($rowset[$key]['title'])?"":"").sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits'])."</span>" : '';


this may seem a bit like splitting hairs but... splitting that $caption check up in 2 phases (check title / check nviews) and generate html code accordingly seems to be a "cleaner" solution and one that gives the user more control over the "Look and Feel" of the output.

Due to lack of config settings for switching hit numbers on or off (maybe in a future release) i linked the "n_views" output to "comment_count" on/off (a temporary solution only).

#447
Code: [Select]

                // Set picture caption
                if ($set_caption) foreach ($rowset as $key => $row){
                          $caption = ($rowset[$key]['title']) ? "<span class=\"thumb_title\">".$rowset[$key]['title'].(($rowset[$key]['title'])?"":"")."</span>" : '';
                        if ($CONFIG['display_comment_count']) {                          
                          $caption .= ($rowset[$key]['hits']) ? "<span class=\"n_views\">".sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits'])."</span>" : '';                        
                        }
                        if ($CONFIG['caption_in_thumbview']){
                           $caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">".bb_decode(($rowset[$key]['caption']))."</span>" : '';
                        }
                        if ($CONFIG['display_comment_count']) {
                                $comments_nr = count_pic_comments($row['pid']);
                                if ($comments_nr > 0) $caption .= "<span class=\"thumb_num_comments\">".sprintf($lang_get_pic_data['n_comments'], $comments_nr )."</span>";
                        }
                        $rowset[$key]['caption_text'] = $caption;
                }


i introduced a new class "n_views" enabling the user to control the "look" of the "viewed" output in css and I split the output up in two spans since I feel the thumb_title deserves a line on it's own and certainly it's own style.

of course the x Hits are still displayed in the same line as the title but in its own style and if you want it to be displayed under it just add a br tag to the n_views string in the language file.

all it needs now is a $CONFIG['display_hits_count'] and it's good to go.

cheers
eke.
Logged

chyne

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
my solution to removing views from captions
« Reply #1 on: December 01, 2003, 07:06:48 am »

I added the following to sql/update.sql:
Code: [Select]

INSERT INTO CPG_config VALUES('views_in_caption', '0');

and then I accessed the update.php file via the web browser (ie. www.example.com/cpg_dir/update.php).

Then I modified line #449 in functions.inc.php to the following:
Code: [Select]
                       $caption = (($rowset[$key]['title']||$rowset[$key]['hits']) ? "<span class=\"thumb_title\">".$rowset[$key]['title'].(($rowset[$key]['title']&&$CONFIG['views_in_caption'])?"-".sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits']):"")."</span>" : '');
The option of turning it off and on via config interface is accomplished by adding the following to the appropriate language file (english.php around line 363 or so, in my case):
Code: [Select]

array('Display number of views in caption', 'views_in_caption', 1),
Logged

epsilon

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 95
    • http://www.cremita.com
Please help...
« Reply #2 on: December 18, 2003, 02:19:43 am »

I have 1.2.0 Final and its not solved, i dont know english well and i cant follow the instructions of these posts, what is the correct solution? The Eke post or the Chyne Post? Can someone put me the steps easily to do it? It will affect me in a future version if i change the code to further uptades? Thnks
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 21 queries.