Advanced search  

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

Pages: [1]   Go Down

Author Topic: [Solved]: trying to use cpmfetch to change coppermine layout  (Read 4261 times)

0 Members and 1 Guest are viewing this topic.

michael.bauer

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
[Solved]: trying to use cpmfetch to change coppermine layout
« on: April 08, 2008, 05:30:12 pm »

Hello!
At first, let me say Im sorry for my bad english. I hope this wont be just a waste of your time.

I want to change the coppermine home-page layout. For this purpose i decided to use cpmfetch plugin in combination with some 3-column-coppermine-templates

[like "Andreas09" e.g. (see http://coppermine-gallery.net/demo/cpg14x/index.php?theme=andreas09)]


The goal is to display recently added pictures in the left column of the 3-column-template (cpmfetch code and the main content side by side). So I want to insert cpmfetch code into (or below) the sub menu located in the left column.

I dont know how to do this.
I´ve read some posts describing how to add the php code into the page but none of them fit to my issue.
As it is impossible to put the code directly into template.html,  the answer is to create a {CUSTOM_TOKEN} in template.html and to replace the {CUSTOM_TOKEN} in the corresponding function in theme.php file, isnt it ?

The question is: Where to edit the code and how ?
As i dont understand the code enough, i failed when trying to do this. I ask for help.
(I found some explanations in similar postings, but none of them fit to my issue.)

Thank you for any help.

------------------------------------------------------

Shall I edit the custom menu function ?
[Andreas09 theme.php]
Code: [Select]
// HTML template for sub menu
$template_sub_menu = <<<EOT
                                        <ul>
<!-- BEGIN custom_link -->
                                            <li><a href="{CUSTOM_LNK_TGT}" title="{CUSTOM_LNK_TITLE}">{CUSTOM_LNK_LNK}</a></li>
<!-- END custom_link -->
<!-- BEGIN album_list -->
                                            <li><a href="{ALB_LIST_TGT}" title="{ALB_LIST_TITLE}">{ALB_LIST_LNK}</a></li>
<!-- END album_list -->
                                            <li><a href="{LASTUP_TGT}" title="{LASTUP_LNK}">{LASTUP_LNK}</a></li>
                                            <li><a href="{LASTCOM_TGT}" title="{LASTCOM_LNK}">{LASTCOM_LNK}</a></li>
                                            <li><a href="{TOPN_TGT}" title="{TOPN_LNK}">{TOPN_LNK}</a></li>
                                            <li><a href="{TOPRATED_TGT}" title="{TOPRATED_LNK}">{TOPRATED_LNK}</a></li>
                                            <li><a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a></li>
                                            <li><a href="{SEARCH_TGT}" title="{SEARCH_LNK}">{SEARCH_LNK}</a></li>
                                        </ul>

Or another place in theme.php ? (attached as txt file)

Or am I absolutely wrong ?
« Last Edit: April 09, 2008, 07:31:31 pm by Joachim Müller »
Logged

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: trying to use cpmfetch to change coppermine layout
« Reply #1 on: April 08, 2008, 06:42:48 pm »

Logged

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: trying to use cpmfetch to change coppermine layout
« Reply #2 on: April 08, 2008, 10:54:28 pm »

Michael,

If you are not already making use of the {CUSTOM_HEADER} option, a simple way would be to use this token to insert your cpmfetch code. Edit the theme template.html to put the {CUSTOM_HEADER} token where you want the images to appear, for example:
Code: [Select]
         <div id="leftside">
            <ul>
               <li id="categories"><h2>Gallery Menu</h2>
                  {SUB_MENU}
                  {CUSTOM_HEADER}
               </li>
            </ul>
         </div><!--End leftside-->

Then use 'Config>>Themes settings>>Path to custom header include' to point to a file containing the cpmfetch code. Just take care to get the relative paths correct. I just tried this on the andreas09 theme and it worked fine.

Wrap the {CUSTOM_HEADER} token in an extra <div> if you want to do some further fancy styling of the pictures.

Steve
Logged

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: trying to use cpmfetch to change coppermine layout
« Reply #3 on: April 08, 2008, 11:26:43 pm »

Michael,

Correction - the {CUSTOM_HEADER} token should be outside the unordered list:
Code: [Select]
         <div id="leftside">
            <ul>
               <li id="categories"><h2>Gallery Menu</h2>
                  {SUB_MENU}
               </li>
            </ul>
            {CUSTOM_HEADER}
         </div><!--End leftside-->

Apologies for any confusion.
Logged

michael.bauer

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: trying to use cpmfetch to change coppermine layout
« Reply #4 on: April 09, 2008, 11:34:50 am »

Hello, steveeh131047,

I very appreciate your help.

First of all i tried to implement the procedure described by scandore8472 (your link above http://forum.coppermine-gallery.net/index.php/topic,49292.0.html). It looks like what i was looking for...!
However, i still cannot compel the code to work properly.
(As you can see at my test website: http://leaves.ic.cz), there is a "{FETCHRANDOM}" text written instead of code (above the page-header), so that the {FETCHRANDOM} token wasnt replaced.

I probably made a mistake i cannot find. I would like to ask for another help:
Can anyone see the mistake i make ?

Here i copied the function "theme_html_picture()" from andreas09's theme.php edited by me accordance with the mentioned procedure http://forum.coppermine-gallery.net/index.php/topic,49292.0.html - all changes were made at the very end of the function and are marked as NEW CODE START and NEW CODE STOP.
Code: [Select]
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($CURRENT_PIC_DATA['pwidth'] > $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_max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);

    $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 . "\" {$image_size['geom']} class=\"intermed_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=\"intermed_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=\"intermed_image\" /></a>\n<br />";
    } else {
        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

        $players['WMP'] = array('id' => 'MediaPlayer',
                                'clsid' => 'classid="" ',
                                '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);
//--------------------------------------------------------------------------------------------------------NEW CODE START----------------------------------------------------------------------------------------//
  include_once "./cpmfetch/cpmfetch.php";
    $objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
    $objCpm->cpm_setReturnType('html');
//--------------------------------------------------------------------------------------------------------NEW CODE STOP------------------------------------------------------------------------------------------//
    $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']),
//--------------------------------------------------------------------------------------------------------NEW CODE START----------------------------------------------------------------------------------------//
        '{FETCHRANDOM}' => $objCpm->cpm_viewRandomMedia(2, 3),
//--------------------------------------------------------------------------------------------------------NEW CODE STOP------------------------------------------------------------------------------------------//
        );
//--------------------------------------------------------------------------------------------------------NEW CODE START----------------------------------------------------------------------------------------//
$objCpm->cpm_close();
//--------------------------------------------------------------------------------------------------------NEW CODE STOP------------------------------------------------------------------------------------------//

    return template_eval($template_display_media, $params);
}

(the complete file also attached).

I havent tried out the other mentioned procedure yet. It looks more simple. However, the first one seems to be more .... ehm.. "powerful" and i am very interested in it.

Thank you all in advance. (and sorry for my primitive "lame" english-language)
Logged

Nibbler

  • Guest
Re: trying to use cpmfetch to change coppermine layout
« Reply #5 on: April 09, 2008, 12:12:03 pm »

theme_html_picture() will only process tokens that are in the $template_display_media template. To process tokens in the template.html you need to apply your change to the pageheader() function.
Logged

michael.bauer

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: trying to use cpmfetch to change coppermine layout
« Reply #6 on: April 09, 2008, 05:32:16 pm »

Now it works. Great !
Thank you for your time, Nibbler, steveeh131047 !
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.