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: Adding Anycontent, random image, last addition to sidebar  (Read 11935 times)

0 Members and 1 Guest are viewing this topic.

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Adding Anycontent, random image, last addition to sidebar
« on: November 26, 2005, 06:59:32 pm »

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
« Last Edit: December 07, 2005, 04:58:33 am by TranzNDance »
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #1 on: November 27, 2005, 06:04:49 pm »

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?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #2 on: November 27, 2005, 07:50:18 pm »

{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.
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #3 on: November 29, 2005, 05:41:03 am »

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!
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #4 on: November 29, 2005, 07:21:27 pm »

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.
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #5 on: November 30, 2005, 05:32:27 am »

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?]
Code: [Select]
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.
Code: [Select]
// 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
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #6 on: November 30, 2005, 05:45:18 am »

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.

Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #7 on: November 30, 2005, 05:55:11 am »

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
Code: [Select]
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?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #8 on: November 30, 2005, 06:01:55 am »

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.
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #9 on: November 30, 2005, 06:11:52 am »

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
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #10 on: November 30, 2005, 06:46:49 am »

Code: [Select]

//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>";
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #11 on: November 30, 2005, 07:00:35 am »

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.
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #12 on: December 06, 2005, 05:11:24 am »

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.
Code: [Select]
// 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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #13 on: December 06, 2005, 09:17:24 am »

issue solved then?
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Adding Anycontent, random image, last addition to sidebar
« Reply #14 on: December 07, 2005, 04:48:50 am »

Consider the case solved Sherlock!  ;)
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 19 queries.