addendum to "thumb_title - viewed" output addendum to "thumb_title - viewed" output
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

addendum to "thumb_title - viewed" output

Started by eke, November 29, 2003, 03:22:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eke

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:

                        $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

                // 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.

chyne

I added the following to sql/update.sql:

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:
                       $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):

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

epsilon

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