Add Album Admin Menu to Album pages? Add Album Admin Menu to Album pages?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Add Album Admin Menu to Album pages?

Started by jojobear99, April 04, 2009, 01:07:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jojobear99

Hi, I am new to coppermine, and I would like to add links to the album admin menu (in particular "PROPERTIES" and "EDIT FILES" for the album) to the album page (url says thumbnails.php) rather than only on the categories page (index.php).

$template_thumb_view_title_row (in my theme.php) appears to be the location I'd like to insert the menu, but I can't figure out how to access the menu in this context...it doesn't appear to be {ADMIN_MENU} but I'm nto sure what else to try.

I am using Coppermine v1.4.19, if that matters. Thank you!

Joachim Müller

The function definition for theme_display_album_list_cat is the key: that function is being called with the parameters for the album list. You need to add your custom menu items to the parameters. To accomplish that, edit themes/yourtheme/theme.php, findfunction theme_display_album_list_cat(&$alb_list, $nbAlb, $cat, $page, $total_pages)and edit as suggested below. If your custom theme doesn't contain that function definition, copy// Function to display first level Albums of a category
function theme_display_album_list_cat(&$alb_list, $nbAlb, $cat, $page, $total_pages)
{
    global $CONFIG, $STATS_IN_ALB_LIST, $statistics, $template_tab_display, $template_album_list_cat, $lang_album_list;
    if (!$CONFIG['first_level']) {
        return;
    }

    $theme_alb_list_tab_tmpl = $template_tab_display;

    $theme_alb_list_tab_tmpl['left_text'] = strtr($theme_alb_list_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_album_list['album_on_page']));
    $theme_alb_list_tab_tmpl['inactive_tab'] = strtr($theme_alb_list_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));

    $tabs = create_tabs($nbAlb, $page, $total_pages, $theme_alb_list_tab_tmpl);
    // echo $template_album_list_cat;
    $template_album_list_cat1 = $template_album_list_cat;
    $album_cell = template_extract_block($template_album_list_cat1, 'c_album_cell');
    $empty_cell = template_extract_block($template_album_list_cat1, 'c_empty_cell');
    $tabs_row = template_extract_block($template_album_list_cat1, 'c_tabs');
    $stat_row = template_extract_block($template_album_list_cat1, 'c_stat_row');
    $spacer = template_extract_block($template_album_list_cat1, 'c_spacer');
    $header = template_extract_block($template_album_list_cat1, 'c_header');
    $footer = template_extract_block($template_album_list_cat1, 'c_footer');
    $rows_separator = template_extract_block($template_album_list_cat1, 'c_row_separator');

    $count = 0;

    $columns = $CONFIG['album_list_cols'];
    $column_width = ceil(100 / $columns);
    $thumb_cell_width = $CONFIG['alb_list_thumb_size'] + 2;

    starttable('100%');

    if ($STATS_IN_ALB_LIST) {
        $params = array('{STATISTICS}' => $statistics,
            '{COLUMNS}' => $columns,
            );
        echo template_eval($stat_row, $params);
    }

    echo $header;

    if (is_array($alb_list)) {
        foreach($alb_list as $album) {
            $count ++;

            $params = array('{COL_WIDTH}' => $column_width,
                '{ALBUM_TITLE}' => $album['album_title'],
                '{THUMB_CELL_WIDTH}' => $thumb_cell_width,
                '{ALB_LINK_TGT}' => "thumbnails.php?album={$album['aid']}",
                '{ALB_LINK_PIC}' => $album['thumb_pic'],
                '{ADMIN_MENU}' => $album['album_adm_menu'],
                '{ALB_DESC}' => $album['album_desc'],
                '{ALB_INFOS}' => $album['album_info'],
                );

            echo template_eval($album_cell, $params);

            if ($count % $columns == 0 && $count < count($alb_list)) {
                echo $rows_separator;
            }
        }
    }

    $params = array('{COL_WIDTH}' => $column_width,
          '{SPACER}' => $thumb_cell_width
          );
    $empty_cell = template_eval($empty_cell, $params);

    while ($count++ % $columns != 0) {
        echo $empty_cell;
    }

    echo $footer;
    // Tab display
    $params = array('{COLUMNS}' => $columns,
        '{TABS}' => $tabs,
        );
    echo template_eval($tabs_row, $params);

    endtable();

    echo $spacer;
}
from themes/sample/theme.php into a new line before?>of themes/yourtheme/theme.php

You will then have to "inject" the additional menu items that are "stored" in $alb_list['album_adm_menu']. A good place to do that would be after echo $header;

However, I'm not sure if you actually want to add genuine admin menu items. You're aware that they will only be displayed for you as admin? If you want to accomplish something else: displaying something for everybody right next to the admin menu items, you should edit the definitions for $template_album_list and $template_album_list_cat instead (the usual drill applies: if those sections don't exist in your custom theme, copy them from themes/sample/theme.php).
Maybe you should explain what you actually want to accomplish, i.e. what exactly you want to display and for which type of visitor (guest, registered user, admin, anybody).