Show latest images of the gallery at the gallery header Show latest images of the gallery at the gallery header
 

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

Show latest images of the gallery at the gallery header

Started by CandyEyes, November 17, 2012, 08:42:04 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

CandyEyes

Hi! I've been searching through the support forum but I didn't find a helpful answer. ..
My site url is http://candyeyes.es and as you can see, in the header, it shows the latets pictures of the coppermine gallery. The thing is that my portfolio (coppermine gallery), which is located here: http://candyeyes.es/portfolio,  has got the same layout as the main site and when I try to make the latest images show up on the header (at http://candyeyes.es/portfolio) they don't show up. I guess this is because I included the cpmfetch code into the coppermine theme template.html code and it doesn't work. I wonder if there's a way to make the latets images show up at my gallery header, to match the main site layout.
Thank you in advance.

Αndré

You cannot include PHP code in template.html (unless you enable parsing of that file types, which is not recommended). But you can add a new token like {CPMFETCH_LATEST} at the desired location, which you can replace with the actual content inside the function pageheader in your theme.php file.

There are already some threads how to add dynamic content to the theme header, which use exactly the above token approach. If you need further assistance, let me know.

CandyEyes

thank you André for your answer. I was trying to convert my template.html to .php cause I was thinking of that, but I didn't know where to make the call to template.php and not template.html. So I thought it wasn't possible, which is what you said.
In fact, I don't know so much of php and I don't know if I got what you said.
Quote from: Αndré on November 20, 2012, 11:05:53 AM
But you can add a new token like {CPMFETCH_LATEST} at the desired location,
By this, do you mean I need to add my cpmfetch files where the theme templates are? cause the files are within the "portfolio" folder, which is where I want the cpmfetch to be showed....
Quote from: Αndré on November 20, 2012, 11:05:53 AMwhich you can replace with the actual content inside the function pageheader in your theme.php file.
so, do I need to add a pageheader function in my theme.php? whihc function would show those images?

Quote from: Αndré on November 20, 2012, 11:05:53 AMThere are already some threads how to add dynamic content to the theme header, which use exactly the above token approach. If you need further assistance, let me know.
I would try to find the code, but if you could lend me a hand, it would be really appreciated.
Thank you so much!

Αndré

Quote from: CandyEyes on November 20, 2012, 02:55:30 PM
do you mean I need to add my cpmfetch files where the theme templates are?
No. Just have a look at template.html and you'll find a lot of tokens, e.g. {SYS_MENU} and {SUB_MENU}. Now, just add your custom token where you want to display your custom content, e.g. {CPMFETCH_LATEST}.

Then you have to copy the function pageheader from themes/sample/theme.php to your theme's theme.php file, if it doesn't already exists. That function is quite short and easy to understand, I guess. You should now be able to use CPMFetch as usual (I hope). I currently don't know if CPMFetch immediately prints the output or if you can also store it in a variable. As a workaround we can still use output buffers. At last hust add your custom token and the stored CPMFetch content to the $template_vars array.

CandyEyes

This is what I did: I added the function and the variable to the theme.php using this code:

function pageheader($section, $meta = '',$cpmfetch_latest='')
{<?php

  
include "/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch_config.php");
  
$options = array( 'imageheight' => '40''imagewidth' => '30''imagestyle' => 'image100');
  
$objCpm->cpm_viewLastAddedMedia(2,6$options);
  
$objCpm->cpm_close();
?>

'{CPMFETCH_LATEST}'    => $cpmfetch_latest,
}
$template_vars = array('{LANG_DIR}' => $lang_text_dir,
       
'{CPMFETCH_LATEST}'  => $cpmfetch_latest, // Mod for Custom login box + statistics
        );

    echo template_eval($template_header, $template_vars);
}


then I added the {CPMFETCH_LATEST} where I wanted the latest pictures to be showed in the template.html, like example, in here:

<td background="themes/copp9/header_04.gif" width="280" height="129" alt=""><div

align="center">{CPMFETCH_LATEST}
  </div></td>


and the result was nothing...my http://candyeye.es/portfolio is in blank.
What am I doing wrong?
Thank you for your time.

Αndré

For a start remove
<?php
and
?>

Additionally, the line
'{CPMFETCH_LATEST}'    => $cpmfetch_latest,
will return a parse error and it seems that you removed other important stuff from the function pageheader.

CandyEyes

Hi, I did as you said. and the latest images are showing, just before the header, not within the header....I added {CPMFETCH_LATEST} where I wanted them to show but they just show up at the top (you can see at http://candyeyes.es/portfolio ....how can I make them show within the header? do I need to call {CUSTOM_HEADER} in template.html and add the custom header code in the theme.php so it will work? cause I tried to do that, but didn't work....
Thank you so much, André! at least, they're showing up...so I guess now it's just code stuff....

CandyEyes

Sorry, forgot to add, now the function pageheader looks like this:

function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

include "/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch_config.php");
  $options = array( 'imageheight' => '40', 'imagewidth' => '30', 'imagestyle' => 'image100');
  $objCpm->cpm_viewLastAddedMedia(2,6, $options);
  $objCpm->cpm_close();

    $template_vars = array(
        '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => theme_page_title($section),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{MESSAGE_BLOCK}' => theme_display_message_block(),
'{CPMFETCH_LATEST}'  => $cpmfetch_latest,
    );
   
    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}

Αndré

Try to replace
include "/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch_config.php");
  $options = array( 'imageheight' => '40', 'imagewidth' => '30', 'imagestyle' => 'image100');
  $objCpm->cpm_viewLastAddedMedia(2,6, $options);
  $objCpm->cpm_close();

with
    ob_start();
    include "/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch.php";
    $objCpm = new cpm("/home/candyeye/public_html/portfolio/cpmfetch/cpmfetch_config.php");
    $options = array( 'imageheight' => '40', 'imagewidth' => '30', 'imagestyle' => 'image100');
    $objCpm->cpm_viewLastAddedMedia(2,6, $options);
    $objCpm->cpm_close();
    $cpmfetch_latest = ob_get_flush();

CandyEyes

I did as you said. And yeah, they're showing in the header, right where I wanted,but.....they're still showing on the top of the pàge too....any clue why they're showing twice? I've been looking the code and deleting some...but no reasult. Sorry, to be asking all over again, but I have no idea of this stuff....how can I make the latest pictures at the very top of the page (repeated) disappear? I guess this should be the latest step to solve the thread. thank you so much for everything!

Αndré

Sorry, my mistake. Use ob_get_clean instead of ob_get_flush.

CandyEyes

Quote from: Αndré on November 24, 2012, 08:45:43 AM
Sorry, my mistake. Use ob_get_clean instead of ob_get_flush.

It worked! Omg, thank you so much André for helping me with this! I thought it wasn't possible to do this but it is....thank you for your time and for being pathient with me as I don't understand the code.

CandyEyes

In fact, I had a problem with the characters when I added the cpmfetch function code, now the special characters are not showing correctly. I wonder if I should open a new thread with this as the forum rules say one thread for each thing, but as it's directly related with this, I don't know if I should continue in this one....I've been looking on the forum, and could it be a problem with UTF8 or language coding? cause I swear I didn't change anything more than adding the code writen all along this thread. Thanks.

Αndré

The issue is probably related to CPMFetch, so please start a new thread. I never used CPMFetch, so I'm not sure if I can solve your issue (but maybe somebody else can).

CandyEyes

Quote from: Αndré on November 24, 2012, 06:46:44 PM
The issue is probably related to CPMFetch, so please start a new thread. I never used CPMFetch, so I'm not sure if I can solve your issue (but maybe somebody else can).
Alright! thanks.