0

enter image description hereI am using Node Gallery module to work with albums and photos uploaded by user. When a user views his album there is a tab called Manage Photos which displays table with headings Delete, Preview, Edit and Cover.

I want to change the text of 'Cover' as 'Album Cover' and display 'Delete' column at the end.

How to do this??

1
  • Can you share the tab images?
    – Inizio
    Commented Jul 2, 2014 at 7:48

1 Answer 1

2

There is a Theming Function inside the theme.inc (\node_gallery\theme\theme.inc) file:

theme_node_gallery_api_manage_items_form($variables)

In there is everything you need. Copy this whole function to your template.php, rename the function to YOURTHEMENAME_node_gallery_api_manage_items_form($variables) and change the desired text. I think this should to the trick.

Paste the below code inside your active theme template.php file and make sure to change to you theme name.


    /**
     * Theme function for Manage Items form.
     */
    function elegant_theme_node_gallery_api_manage_items_form($variables) {
        $form = $variables['form'];

        if (empty($form['items'])) {
            return t('This gallery is empty.');
        }
        // Pull in the multi-select functionality from core.
        drupal_add_js('misc/tableselect.js');
        // Get fieldname to retrieve the filepath for the thumbnail without
        // loading the node.
        $relationship_type = node_gallery_api_get_relationship_type($form['#gallery']->type);
        $enable_rotation = FALSE;
        if ($relationship_type->settings['manage_items']['enable_rotation'] && (image_get_toolkit() != 'gd' || function_exists("imagerotate"))) {
            $enable_rotation = TRUE;
            drupal_add_library('system', 'ui.dialog');
            drupal_add_library('system', 'ui.draggable');
            drupal_add_library('system', 'ui.resizable');
            drupal_add_js(drupal_get_path('module', 'node_gallery') . '/js/ng_manage_images.js');
        }
        $header = array(
            t('Album Cover'), //changed from Cover to Album Cover
            t('Preview'),
            t('Edit'),
            array(
                'data' => t('Delete'),
                'class' => 'select-all',
            ),
        );
        if ($enable_rotation) {
            $header = array(
                t('Album Cover'), //changed from Cover to Album Cover
                t('Preview'),
                t('Edit'),
                t('Rotation'),
                array(
                    'data' => t('Delete'),
                    'class' => 'select-all',
                ),
            );
        }
        $rows = array();
        foreach (element_children($form['items']) as $nid) {
            $element = &$form['items'][$nid];

            $row = array();
            //Cover checkbox
            if ($form['is_cover']) {
                $row[] = drupal_render($form['is_cover'][$nid]);
            }
            //preview
            $file = $element['item_file']['#value'];
            if (!empty($file)) {
                $file_object = (object) $file;
                $file_view = file_view($file_object, 'node_gallery_api_admin_thumbnail');
                $row[] = drupal_render($file_view);
            }
            else {
                $row[] = '';
            }
            //edit link
            $edit = drupal_render($element['edit_form']);
            if (!empty($element['ngid'])) {
                $edit .= drupal_render($element['ngid']);
            }
            $row[] = $edit;
            //Rotation
            if ($enable_rotation && !empty($file) && $file['type'] == 'image') {
                $row[] = drupal_render($element['rotate']);
            }
            elseif ($enable_rotation) {
                drupal_render($element['rotate']);
                $row[] = '';
            }

            $row[] = drupal_render($element['remove']);
            $rows[] = array('data' => $row);
        }
        $output = theme('table', array(
            'header' => $header,
            'rows' => $rows,
            'attributes' => array('id' => 'upload-attachments'),
            )
        );
        $output .= theme('pager');
        $output .= drupal_render_children($form);
        return $output;
    }
4
  • @inizio Thanks!the above code is working correct but the labels for delete and album cover are not getting rotated, despite the delete checkboxes are displayed at end and radiobutton to set album cover is in the first column.I am not getting how to display the labels to their correct place i.e.Album cover in first column & Delete label with select all checkbox in last column.
    – 12345
    Commented Jul 3, 2014 at 6:50
  • Have you cleared the cache? if possible can you share screenshots? Above code switches the headers too.
    – Inizio
    Commented Jul 3, 2014 at 7:12
  • Yes i have cleared cache but headers are not getting rotated.I have attached screenshot of how it looks.
    – 12345
    Commented Jul 3, 2014 at 7:38
  • Thanks for sharing the image. I have fixed the problem, you can use the updated code.
    – Inizio
    Commented Jul 3, 2014 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.