Adding Anycontent, random image, last addition to sidebar Adding Anycontent, random image, last addition to sidebar
 

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

Adding Anycontent, random image, last addition to sidebar

Started by myself, November 26, 2005, 06:59:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

myself

Is it possible to seperate anycontent, caltegory listing, random image, last addition from {GALLERY} so that it can be included in a sidebar? If so, is it also possible to override config settings so that only one random image and only one last addition is shown?

Lastly, how?

Thanks,

D

myself

I may have laready started to figure out my own problem, but need some help detemining where the code lies. I can define how these items are displayed, inside of a <tr> however, it would be nice if I could also specify the table and not have {GALLERY} call the <table>. Is there a way of changing that in the template.php? Or something like that?

donnoman

{GALLERY} Isn't really a token like the other {ITEMS} in the theme, its more of a separator.

{GALLERY} Isn't replaced with content, rather the template is split into two at {GALLERY} everything before it is put in $template_header, and everything after it is put into $template_footer. The token {GALLERY} is effectively discarded.

The functions pageheader() and pagefooter() evaluate those items and produce the page.

Look at the sample theme to see how you can override these functions and the templates.

myself

OK I see what you are saying, I have spent time looking at the code, unfortunately php is not my strong point, I usually do my web work in VB and I am still trying to figure this thing out. I have found the pagefooter() but how do I call, say, the last additions to the footer. Is it possible to have this table formatted differently then then the main? Look at the page I am working on. http://acollectionof.myphotos.cc (Select the theme "create". I have a menu on the left side, I would like to have a matching right hand bar that contains; anycontent/ breadcrumb, random pics (1), last addition (1). I can get the man table positioned to the left making ready for tables on the right but have not quite got it yet, a bit dense on my part. I think I might abandon the idea. I have not seen any examples that come close to the idea I am looking for, so I do not know if is possible without a great deal of work, which I may not be able to do.

Any help is moving this forward would be beneficial.

Thanks!

donnoman

if the content you are adding comes AFTER the {GALLERY} token then you have to deal with it in pagefooter.

But I might suggest actually learning about CSS absolute positioning, this might do the trick, perhaps even if you did a float right of that menu.

myself

I have studied the Sample code as you suggested, and have started to come up with a solution. It looks like it will work, I added an agrument to the starttable:
function starttable($width = '-1', $title = '', $title_colspan = '1', $align='left') This way, depending on the table, I can pass along a specific width and alignment. It appears to work with the breadcrumb section. Unfortunately, there is not adisplay function for anycontent, random image/ last addition as there is for breadcrumb. How can I modify the following code for anycontent, random and last addition.
[Side note: Is it possilble to display only 1 image for these?]
function theme_display_breadcrumb($breadcrumb, &$cat_data)
{
    /**
     * ** added breadcrumb as a seperate element
     */
    global $template_breadcrumb, $lang_breadcrumb;

    starttable('175','','1','right');
    if ($breadcrumb) {
        $template = template_extract_block($template_breadcrumb, 'breadcrumb');
        $params = array('{BREADCRUMB}' => $breadcrumb
            );
        echo template_eval($template, $params);
    }
        endtable();
}


I also need to the tokens (?) to apply to the HTML code for the above as well.
// HTML template for the breadcrumb
$template_breadcrumb = <<<EOT
<!-- BEGIN breadcrumb -->
        <tr>
                <td colspan="3" align="left" class="tableh1"><span class="statlink"><b>{BREADCRUMB}</b></span></td>
        </tr>
<!-- END breadcrumb -->
<!-- BEGIN breadcrumb_user_gal -->
        <tr>
                <td colspan="3" class="tableh1">
                <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                        <td align="left"><span class="statlink"><b>{BREADCRUMB}</b></span></td>
                        <td align="right"><span class="statlink"><b>{STATISTICS}</b></span></td>
                </tr>
                </table>
                </td>
        </tr>
<!-- END breadcrumb_user_gal -->


There are obviously other formatting issues, but I might just get this to work. Thanks for all of your help although they have not provided me with direct solutions, they have been extremely useful in getting me thinking down the right path.  Thanks again, D

donnoman

Your immediately going to have a problem, since the default handling of randoms and last updated is 1 row, not 1 picture.

If I were you I'd add a token to your template.html where you want this right hand bar to be. Turn off lastup/random in content of main page.

Then in pagefooter, make the replacement as if you were making a custom footer for 1.3.

To build the replacement you'll probably need to use direct calls to get_pic_data in functions.inc.php. If you set limit1 = 0 and limit2 =1 you will get a single image.


myself

WOW, what a speedy reply, Thanks! Yay I noticed, I have found the section that controls the random image and last updated. Check it out. http://acollectionof.myphotos.cc/index.php?cat=30

function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode =

'thumb')

..

//random and last additions
    if ($mode == 'thumb') {
        starttable('200', $title, $thumbcols,'right');
    } else {
        starttable('200','','1','right');
    }

    echo $header;

    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            } else {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );
            }
        } else {
            $params = array('{CELL_WIDTH}' => $cell_width,
                '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                '{THUMB}' => $thumb['image'],
                '{CAPTION}' => $thumb['caption'],
                '{ADMIN_MENU}' => ''
                );
        }
        echo template_eval($thumb_cell, $params);

        if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
            echo $row_separator;
        }
    }
    for (;($i % $thumbcols); $i++) {
        echo $empty_cell;
    }
    echo $footer;

    if ($display_tabs) {
        $params = array('{THUMB_COLS}' => $thumbcols,
            '{TABS}' => $tabs_html
            );
        echo template_eval($tabs, $params);
    }

    endtable();
    echo $spacer;
}


But as you suggested I have an entire row and not a single image. Can I call up the get image function here and set the limits to that function from within this theme.php?

donnoman

like i said, look at function get_pic_data in include/functions.inc.php

It will return you a RAW array of picture data, you will then have to write the html for your block to do what you want with it.

myself

Thanks again, I have looked at the functions file, but I just do not understand how to calll it up and write the code. If I had an example to work off of I am sure I could, but I could not find and example. You have been very patient. Can you offer a bit more detailed explaination for me as to how to incorporate this into the code? I appreciate any help. Thanks again D

donnoman



//grab a single random image
$custom_pic_data=get_pic_data('random', $count, $album_name,0, 1, false); //returns an array even if its only one item
$custom_pic_data=current($custom_pic_data); //grabs the first item
$url=get_pic_url($custom_pic_data, 'thumb');
echo "<a href=\"displayimage.php?pos=-{$custom_pic_data['pid']}\"><img src=\"$url\"/></a>";

//grab the last uploaded
$custom_pic_data=get_pic_data('lastup', $count, $album_name,0, 1, false); //returns an array even if its only one item
$custom_pic_data=current($custom_pic_data); //grabs the first item
$url=get_pic_url($custom_pic_data, 'thumb');
echo "<a href=\"displayimage.php?pos=-{$custom_pic_data['pid']}\"><img src=\"$url\"/></a>";

myself

Thanks, I just need to try to figure out how to get this into the template.php so that it can be displayed in the document. You have been very helpful even though I have not quite got it. I'm trying to find a bit of a model to use as a basis to set this up on.  Thanks again.

myself

Thanks for all of your help. After not hearing from anyone the dove into the code and after a bit of trial and error, I got some good results. I took the suggestions and the suggested code in as follows.// Function for writing a pagefooter
function pagefooter()
{
    //global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer, $template_random_image, $template_last_image;

    $custom_footer = cpg_get_custom_include($CONFIG['custom_footer_path']);

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }

//grab a single random image
$custom_pic_data_random=get_pic_data('random', $count, $album_name,0, 1, false);
//returns an array even if its only one item
$custom_pic_data_random=current($custom_pic_data_random);
//grabs the first item
$url_random=get_pic_url($custom_pic_data_random, 'thumb');

//grab the last uploaded
$custom_pic_data_last=get_pic_data('lastup', $count, $album_name,0, 1, false);
//returns an array even if its only one item
$custom_pic_data_last=current($custom_pic_data_last);
//grabs the first item
$url_last=get_pic_url($custom_pic_data_last, 'thumb');


    $template_vars = array(
        '{CUSTOM_FOOTER}' => $custom_footer,
        '{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL') && $CONFIG['vanity_block']) ? theme_vanity() : '',
'{RANDOM_IMAGE}' => "<a href=\"displayimage.php?pos=-{$custom_pic_data_random['pid']}\"><center><img src=\"$url_random\"/ class=\"image\" ></center></a>",
'{LAST_IMAGE}' => "<a href=\"displayimage.php?pos=-{$custom_pic_data_last['pid']}\"><center><img src=\"$url_last\"/ class=\"image\" ></center></a>",

    );

    echo template_eval($template_footer, $template_vars);
}

I then put in the {RANDOM_IMAGE} and {LAST_IMAGE} tokens in my template.

I would like to try to modify the code so that it only looks in the current album, like the Gallery Random image and views only images with the correct permissions (I have not tested this.) But I do not know where to start, but that can be left for another day.

Thanks again,
D

Joachim Müller


myself