cosmetic code change: thumb_title output cosmetic code change: thumb_title 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

cosmetic code change: thumb_title output

Started by eke, November 28, 2003, 04:00:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eke

file: theme.php
view: thumbnails


            <table width="100%" cellpadding="0" cellspacing="0" class="thumb_cell">
                        <tr>
                                <td align="center" style="text-align:center" valign="middle">
                                        <a href="displayimage.php?..."></a><br />
                                        <span class="thumb_title"></span>
                                       
                                </td>
                        </tr>
                </table>


I would like to make the line dependant on whether there is a thumb_title or not, i.e. output the html code only if it's not blank.

<span class="thumb_title"></span>

where would I need to edit this? Thanks for any pointers.

cheers eke.

Oasis

hmmm... I don't get what you are saying here..

"thumb_title" is a class defined in style.css of each theme, so basically, since you're obviously using a theme, "thumb_title" is never going to be blank, unless you delete it from the css file.
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

eke

i dont mean the class. i know it's in the css

the variable thumb_title will be rendered inside that span tag, if there's a title that is.

since the class has layout attributes, some browsers will render these attributes whether there is a title or not so all I am saying is that I do not want the script to output that span line if there's no thumb title (in the db).

sinc I am new to this script I have yet to find my way into all the script parts. I am sure this is easily solved with one "if", just have to find where to put it.

cheers
eke.

Oasis

ah! I understand what you mean now...
However, I do not seem to be able to find the code you are refering to in theme.php
Pixnet Gallery: http://www.pixnet.net
iNSiGNiA Weblog: http://www.jayliu.org

eke

it's encapsulated in another file you will only find {CAPTION} in the theme.php file, namely the one in the thumbnail view section.

a bit further down in theme.php there's also a function filling the array for the thumbnail output.

theme.php
-> html template around line 344:
$template_thumbnail_view

-> and around line 1138:
function theme_display_thumbnails ...

I think the "logic" for {CAPTION} is located in another file...?

EZ

eke,

I don't fully understand why you need to the tags when there's no caption. Standards compliant browsers will not display anything if there are tags the enclose a zero-length string.

The code that generates the value that ends up in {CAPTION} is in the file include/functions.inc.php line #451:$caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">".bb_decode(($rowset[$key]['caption']))."</span>" : '';
It looks like it already does (or tries to do) exactly what you want: it only generates the tags if there's a caption, and returns an empty string if there's no caption.

If you still get the tags with nothing in between, then maybe there's a space or another invisible string that triggers the condition which builds the  caption tags. Try to view the output with a hex editor (frhed is a nice free tool), or if you can query your DB then you can try to check the raw data.

Anyway I think it's a big effort for no reason, as the tags don't do any harm - at least with IE6 and Mozilla 1.5  which I've verified.

Eyal.

eke

that's strange. in opera I get a full line more space under the thumbnails with the span line there. I have to check my captions strings in the DB. Only the last thumbnail in the list has no span line. all others have the empty span line...

but as you say the code should only render it if there is a caption...

checking my db...
thanks for the reply.

cheers
eke.

EZ

Can you provide a link to your gallery - I'll try to check with IE/Mozilla and see what happens.

eke

ahhh duh! it's the thumb_title line
it 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>" : '';


since I commented out the nview in the language file it did not show the nview number...
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.

I split it up and due to lack of config settings for switching hit numbers on or off i linked it 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.

cheers
eke.