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: Show latest images of the gallery at the gallery header  (Read 7010 times)

0 Members and 1 Guest are viewing this topic.

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Show latest images of the gallery at the gallery header
« on: November 17, 2012, 08:42:04 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show latest images of the gallery at the gallery header
« Reply #1 on: November 20, 2012, 11:05:53 am »

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

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Re: Show latest images of the gallery at the gallery header
« Reply #2 on: November 20, 2012, 02:55:30 pm »

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.
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....
which 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?

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.
I would try to find the code, but if you could lend me a hand, it would be really appreciated.
Thank you so much!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Re: Show latest images of the gallery at the gallery header
« Reply #3 on: November 20, 2012, 03:05:57 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.
Logged

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Show latest images of the gallery at the gallery header
« Reply #4 on: November 21, 2012, 09:09:16 pm »

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

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

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show latest images of the gallery at the gallery header
« Reply #5 on: November 22, 2012, 08:12:41 am »

For a start remove
Code: [Select]
<?phpand
Code: [Select]
?>
Additionally, the line
Code: [Select]
'{CPMFETCH_LATEST}'    => $cpmfetch_latest,will return a parse error and it seems that you removed other important stuff from the function pageheader.
Logged

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Show latest images of the gallery at the gallery header
« Reply #6 on: November 22, 2012, 02:49:25 pm »

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

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Show latest images of the gallery at the gallery header
« Reply #7 on: November 22, 2012, 02:50:43 pm »

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

Code: [Select]
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();
}
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show latest images of the gallery at the gallery header
« Reply #8 on: November 23, 2012, 07:01:07 pm »

Try to replace
Code: [Select]
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
Code: [Select]
    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();
Logged

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Show latest images of the gallery at the gallery header
« Reply #9 on: November 23, 2012, 08:43:02 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show latest images of the gallery at the gallery header
« Reply #10 on: November 24, 2012, 08:45:43 am »

Sorry, my mistake. Use ob_get_clean instead of ob_get_flush.
Logged

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Re: Show latest images of the gallery at the gallery header
« Reply #11 on: November 24, 2012, 12:27:19 pm »

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

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Show latest images of the gallery at the gallery header
« Reply #12 on: November 24, 2012, 02:01:14 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show latest images of the gallery at the gallery header
« Reply #13 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).
Logged

CandyEyes

  • Coppermine novice
  • *
  • Country: es
  • Offline Offline
  • Gender: Female
  • Posts: 20
    • CandyEyesDeisgns
Re: Re: Show latest images of the gallery at the gallery header
« Reply #14 on: November 24, 2012, 06:53:34 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 20 queries.