forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: MadMaxx on July 24, 2008, 11:05:40 pm

Title: Clickable and Searchable image description Custom field
Post by: MadMaxx on July 24, 2008, 11:05:40 pm
hi

I added an image description custom field named 'Artist', in thumbnail view and in intermediate view (pic1 and pic2)
i'd like to be able to click on that name and do a search of all pics created by that artist.

i did a search and found this old article http://forum.coppermine-gallery.net/index.php/topic,3396.msg14936.html#msg14936
but it didn't work, probably made for an earlier version.

any help would be really appreciated, thank you.
Title: Re: Clickable and Searchable image description Custom field
Post by: Joachim Müller on July 25, 2008, 07:00:20 am
http://coppermine-gallery.net/demo/cpg14x/docs/faq.htm#linksInCustomFields
Title: Re: Clickable and Searchable image description Custom field
Post by: MadMaxx on July 27, 2008, 10:51:50 pm
Thank you for your quick answer , but that's not what i was looking for.
That only works if you use bbcode, in this case the user enters the artist's name only (no bbcode)
and clicking the name would search the gallery for all images created by that artist.

I found a way and it seems to work:

first i used this info provided by nibbler here: http://forum.coppermine-gallery.net/index.php/topic,38804.0.html
to make the custom field a default search field.

then for the intermediate view (pic2) i changed the code in displayimage.php
from
Code: [Select]
for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
}else{
    $info[$CONFIG['user_field' . $i . '_name']] ='Unknown';
            }
        }
to
Code: [Select]
for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
$info[$CONFIG['user_field' . $i . '_name']] = '<a href ="thumbnails.php?album=search&search='.$CURRENT_PIC_DATA['user' . $i].'">'.$CURRENT_PIC_DATA['user' . $i].'</a>';
}else{
    $info[$CONFIG['user_field' . $i . '_name']] ='Unknown';
            }
        }

for the thumbnail view (pic1) i used the code provided by stramm here: http://forum.coppermine-gallery.net/index.php/topic,27654.0.html
to add a custom field to the thumbnail view, and changed the code
from
Code: [Select]
if ($row['user1']) {
           $user1_temp = $row['user1'];
        } else {
           $user1_temp = 'Unknown';
        }
$caption .= '<span style="font-weight:bold;">'."Artist: ".'</span>'.'<span style="color:red;font-weight:bold;">'.$user1_temp.'<br /></span>';
to
Code: [Select]
if ($row['user1']) {
           $user1_temp = $row['user1'];
        } else {
           $user1_temp = 'Unknown';
        }
$caption .= '<span style="font-weight:bold;">'."Artist: ".'</span>'.'<span style="color:red;font-weight:bold;"><a href ="thumbnails.php?album=search&search='.$user1_temp.'">'.$user1_temp.'</a><br /></span>';