How to add different links on different Albums? How to add different links on different Albums?
 

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

How to add different links on different Albums?

Started by Stacys, October 01, 2013, 06:13:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stacys

Dear admins, users,

I would like to ask you kindly for you help.
I modified file 'themes.inc.php' and got these links below intermediate size image. These links are shown on ALL photos in ALL albums in my gallery.
Now what I want to do- to add a particular link on ONE PARTICULAR ALBUM ONLY.
On other albums' photos there should be another link, o the third album- third link etc. Is it possible? What file I should edit, what code and where to insert?

Gallery version 1.5.22
Theme: hardwired

Thank you very much in advance.

Stacys

Dear friends,

any thoughts how to do this?
I really need help...

Short repeat: I need to add a link below intermediate picture, but it must be shown on ONE specific album only.

Thank you in advance.

Niecher

In the configuration of the gallery, you can create a custom field.

This field appear in the file information, for example: RESERVED.

And in this area you can put: Yes, No, link or any data you need.

Then you just need to edit the images concrete and fill the field.

Regards.

Stacys

Dear Niecher, thank you million times!!
It's a beginning of solution. I really live in nightmare with this question..

I see that you know how to do that. Now it's a bit problematic for me to do it with scripts. I'm not very good specialist of PHP, although did a lot of various changes in gallery. PLEASE, could you explain more detailed, what scripts in what files concretely I should add??

I don't want to waste your time, so I'm willing to put this question on a paid forum and I would pay you for scripting.
Please be so kind...

Deepest thanks again!
Stacys

Stacys

Uhh... I got your idea and made it live.
Once again thanks to Niecher for good advice!

It works now BUT... it appears on file information section, deeply below image.
Of course it is better than nothing, but I need a link right away below image, as you see in a picture.

So I still need some help and solution how to do it...


Niecher

Hello Stacys,

You should see on the navigation bar, just to the right of the star to add to favorites, arrows that allow you to go to the previous picture and the next picture (image attached).

Also, can you use two plugin to help users more easily navigate through the intermediate images: Keyboard Navigation for cpg1.5.x and/or Picture navigation plugin for cpg1.5.x

Read each thread and you can see how these plugins work in galleries of other users.

Perhaps I'm misunderstanding your idea and what you need is to browse all images that are RESERVED, although they are located in different albums.

Honestly, this I do not know how. The easiest thing would be to put all pictures RESERVED within the same album.

Regards.

Niecher

Hello Stacys,

Apologies for answering in my post above with an off-topic. :-[

Google made an incorrect translation for me. >:(

Anyway, I would not know how to put a custom field below the intermediate image. :-\

Regards.

Stacys

Dear Niecher,
thank you for replies.

I tried to understand your off-topic post but didn't understand how it's related to my question  :)

But I searched, red and tested 48 sleepless hours and it seems I found something.
I enabled BB code linking and add BB code hyperlink to photo description. It works, and now my desired link appears straight under the Title. It's not exactly what I want (I want it appear straight under the photo), but very close to that. Now I just need to edit manually all photos in specific album.

Big thanks to you Niecher, because you show my the way with custom field, from where I found BB codes possibility.

I can say I found a solution 80% so I think this topic may be closed.

Thanks to all who red and tried to help me!

phill104

Is it the same link in all images in an album? Because you could simply add an if then code so it only displayed on a specific album ID. There is a thread detailing exactly how to do that somewhere, I'll have a look for that later.

In addition, we recommend you make changes to your theme.php file rather than the themes.inc.php so they are not lost after upgrades. Simply copy the block from themes.inc.php to your theme.php and make the changes there.
It is a mistake to think you can solve any major problems just with potatoes.

phill104

OK, here is an old post from Joachim detailing roughly what you are looking for. Hopefully you can adjust it to fit your needs, it was designed for CPG1.4.x but should work here too.

Joachim really is missed around here.

Quote from: Joachim Müller
OK, this is what you need to do: edit theme.php, find the section that defines the output for a particular region and add an if/the switch to it. If the section doesn't exist in theme.php, copy it from the sample theme. Assuming that you want the link displayed beneath the individual pic display, just below title and caption, edit themes/yourtheme/theme.php, find// HTML template for intermediate image display
$template_display_media = <<<EOT
        <tr>
                <td align="center" class="display_media" nowrap="nowrap">
                        <table cellspacing="2" cellpadding="0" class="imageborder">
                                <tr>
                                        <td align="center">
                                                {IMAGE}

                                        </td>
                                </tr>
                        </table>
                </td></tr>
                <tr><td>
                                                <table width="100%" cellspacing="2" cellpadding="0" class="tableb">
                                <tr>
                                        <td align="center">

                                                {ADMIN_MENU}
                                        </td>
                                </tr>
                        </table>





<!-- BEGIN img_desc -->
                        <table cellpadding="0" cellspacing="0" class="tableb" width="100%">
<!-- BEGIN title -->
                                <tr>
                                        <td class="tableb"><center><b>
                                                {TITLE}
                                        </b></center></td>
                                </tr>
<!-- END title -->
<!-- BEGIN caption -->
                                <tr>
                                        <td class="tableb"><center>
                                                {CAPTION}
                                        </center></td>
                                </tr>
<!-- END caption -->
                        </table>
<!-- END img_desc -->
                </td>
        </tr>

EOT;
and edit as suggested below. If you can't find that section in your custom theme, copy that section from themes/sample/theme.php into a new line of themes/yourtheme/theme.php before ?>

This will result in the placeholder tag {CUSTOM_LINK} showing through your output. Now let's populate that custom token. To accomplish this, edit themes/yourtheme/theme.php once more, find the function definition function theme_html_picture() and edit as suggested below. If that function definition doesn't exist in your custom theme, you again need to copy it from themes/sample/theme.php into a new line before ?> of the file themes/yourtheme/theme.php.
Here's what you need to copy in:// Displays a picture
function theme_html_picture()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER;
    global $album, $comment_date_fmt, $template_display_media;
    global $lang_display_image_php, $lang_picinfo;

    $pid = $CURRENT_PIC_DATA['pid'];
    $pic_title = '';

    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
        $USER['liv'] = array();
    }
    // Add 1 to hit counter
    if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) {
        add_hit($pid);
        if (count($USER['liv']) > 4) array_shift($USER['liv']);
        array_push($USER['liv'], $pid);
    }

    if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
      $condition = true;
    }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){
      $condition = true;
    }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){
      $condition = true;
    }else{
     $condition = false;
    }

    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }

    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
        template_extract_block($template_display_media, 'img_desc');
    } else {
        if (!$CURRENT_PIC_DATA['title']) {
            template_extract_block($template_display_media, 'title');
        }
        if (!$CURRENT_PIC_DATA['caption']) {
            template_extract_block($template_display_media, 'caption');
        }
    }

    $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';

    if ($CONFIG['make_intermediate'] && $condition ) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }

    $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']);

    $pic_title = '';
    $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);


    if ($mime_content['content']=='movie' || $mime_content['content']=='audio') {

        if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) {
            $CURRENT_PIC_DATA['pwidth']  = 320; // Default width

            // Set default height; if file is a movie
            if ($mime_content['content']=='movie') {
                $CURRENT_PIC_DATA['pheight'] = 240; // Default height
            }
        }

        $ctrl_offset['mov']=15;
        $ctrl_offset['wmv']=45;
        $ctrl_offset['swf']=0;
        $ctrl_offset['rm']=0;
        $ctrl_offset_default=45;
        $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default;
        $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"';
    }

    if ($mime_content['content']=='image') {
        if (isset($image_size['reduced'])) {
            $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
            $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
        }
    } elseif ($mime_content['content']=='document') {
        $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"".$pic_thumb_url."\" border=\"0\" class=\"image\" /></a>\n<br />";
    } else {
        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

        $players['WMP'] = array('id' => 'MediaPlayer',
                                'clsid' => 'classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" ',
                                'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',
                                'mime' => 'type="application/x-mplayer2" ',
                               );
        $players['RMP'] = array('id' => 'RealPlayer',
                                'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ',
                                'codebase' => '',
                                'mime' => 'type="audio/x-pn-realaudio-plugin" '
                               );
        $players['QT']  = array('id' => 'QuickTime',
                                'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ',
                                'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ',
                                'mime' => 'type="video/x-quicktime" '
                               );
        $players['SWF'] = array('id' => 'SWFlash',
                                'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',
                                'codebase' => 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ',
                                'mime' => 'type="application/x-shockwave-flash" '
                               );
        $players['UNK'] = array('id' => 'DefaultPlayer',
                                'clsid' => '',
                                'codebase' => '',
                                'mime' => ''
                               );

        if (isset($_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'])) {
            $user_player = $_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'];
        } else {
            $user_player = $mime_content['player'];
        }

                // There isn't a player selected or user wants client-side control
        if (!$user_player) {
            $user_player = 'UNK';
        }

        $player = $players[$user_player];

        $pic_html  = '<object id="'.$player['id'].'" '.$player['clsid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";
    }

    $CURRENT_PIC_DATA['html'] = $pic_html;
    $CURRENT_PIC_DATA['header'] = '';
    $CURRENT_PIC_DATA['footer'] = '';

    $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA);

    $params = array('{CELL_HEIGHT}' => '100',
        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
        );

    return template_eval($template_display_media, $params);
}
Now let's look at the placeholder definitions: below        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],, add the line        '{CUSTOM_LINK}' => 'foo',Save the whole enchilada and preview the result: below the image, the output {CUSTOM_LINK} should by now have changed to foo, so we have populated the placeholder token alright. Now let's populate it with something that makes sense. In themes/yourtheme/theme.php, find our newly added line        '{CUSTOM_LINK}' => 'foo',and replace with        '{CUSTOM_LINK}' => $custom_link_code,This will result in nothing spectular, as the variable we use for replacement hasn't been populated yet. Now on to the final step: we need to populate that variable. We'll do so a few lines above, so after    $CURRENT_PIC_DATA['footer'] = '';(just 6 lines upwards), add this (into a new line):    $custom_link_code = '';
    if ($CURRENT_PIC_DATA['aid'] == 6) {
    $custom_link_code = 'Hello world. This is the <a href="http://example.com/">custom link</a>';
    }
Edit the condition (if ($CURRENT_PIC_DATA['aid'] == 6) {) - the number ("6" in my example) is the album ID. Edit the actual message and custom link ($custom_link_code = 'Hello world. This is the <a href="http://example.com/">custom link</a>';) as you see fit.

This should be all.
It is a mistake to think you can solve any major problems just with potatoes.

Stacys

Dear Phill.
thank you very much for your attention and help.

Yes, the link is the same in all images in one specific album. I was ready to place it manually but with your help I'll do it much easier, because on some albums there are 2-3 thousands photos.. ;)

I appreciate your time and help- will check and try these advices.
Will write later how successful I was..

Regards,
Stacys

Niecher

Ohhh yes, now I see it clearly.

Thank you so much for your help Phill.

Regards.