Advanced search  

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]

Pages: [1]   Go Down

Author Topic: How to include a custom footer?  (Read 6991 times)

0 Members and 1 Guest are viewing this topic.

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« on: October 27, 2003, 05:33:51 pm »

I'm a bit confused here... There was an explanation on the faq.htm about how to add a custom header to CPG. Ok, did that, and all is working just fine. But how can I add a custom FOOTER to my CPG? It must be a 'function pagefooter', right? But how to change or edit that function? :roll:

cpg1.2.0rc2 here.

Any help is appreciated!
Logged

DJMaze

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 831
    • Dragonfly CMS
How to include a custom footer?
« Reply #1 on: October 27, 2003, 06:04:08 pm »

Open your template.html files and add your footer below {GALLERY}

Or the nicer approach:
Open theme.php and echo something above $template_footer
Logged
There are 2 kinds of users in this world: satisfied and complainers.
Why do we never hear something from the satisfied users?
http://coppermine-gallery.net/forum/index.php?topic=24315.0

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #2 on: October 27, 2003, 06:34:05 pm »

Code: [Select]
<?php include &#40;'/path/to/my/footer.tpl'&#41;; ?> won't work on template.html.
I tried to add this line to theme.php as well, but no luck. The script gives me a "warning: can't open bla-blah" error (though the footer.tpl is in right place).

More ideas?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
How to include a custom footer?
« Reply #3 on: October 28, 2003, 07:55:56 am »

hm, did you insert your include statement right before (or after)
Code: [Select]
echo $template_footer;in theme.php (mind you: absolute path, not relative!)?
What should the ending .tpl hint to? Usually tpl is not being parsed by PHP, so there's little use of just including a text file dynamically - you could as well use the variant with template.html
If you had in mind to use a template (e.g. from phpBB) and use it in Coppermine, then you're wrong. This is not meant to work.

GauGau
Logged

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #4 on: October 28, 2003, 02:22:38 pm »

OK, this is what I have in theme.php:
Code: [Select]
function pageheader($section, $meta = '')  
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;


//        THIS IS MY ADDITION

if(empty($custom_header)){
require("/absolute/path/to/my/header.txt");
$custom_header = ob_get_contents();
ob_clean();
}

//        ADDITION END

   header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
   user_save_profile();
                 
   $template_vars = array(
      '{LANG_DIR}' => $lang_text_dir,  
      '{TITLE}' => $CONFIG['gallery_name'].' - '.$section,
      '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset :

$CONFIG['charset'],
      '{META}' => $meta,
      '{GAL_NAME}' => $CONFIG['gallery_name'],
      '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],    
      '{MAIN_MENU}' => theme_main_menu(),
      '{ADMIN_MENU}' => theme_admin_mode_menu(),  
      '{CUSTOM_HEADER}' => $custom_header,                  // <- THIS LINE IS ADDED, TOO
   );
   
   echo template_eval($template_header, $template_vars);  
}  

And I added {CUSTOM_HEADER} to the top of  template.htm.

So far is all just fine. But when I try to add a footer part, it messes up my whole page.
Code: [Select]

      include("/absolute/path/to/my/footer.txt");
      echo $template_footer;
}


I tried to change the order ( echo  BEFORE include statement), but nothing...

huh, I'm in trouble  :roll:
Logged

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #5 on: October 28, 2003, 02:34:25 pm »

or maybe I have to add
Code: [Select]
include ('/absolute/path/to/my/footer.txt'); manually to every .php file?
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
How to include a custom footer?
« Reply #6 on: October 28, 2003, 06:40:39 pm »

No, that will not work.

Here is an example for the use of echo

echo "<br><br>Copyright 2003. All rights reserved.<br>";
echo $template_footer;


Alternatively, you might try:

// Create Custom Footer
if(empty($custom_footer)){
require("/absolute/path/to/my/footer.txt");
$custom_footer = ob_get_contents();
ob_clean();
}

and place immediately after the similar code for the header (no later, or it will not work). Then add

'{CUSTOM_FOOTER}' => $custom_footer,

to the array list.

Next, place {CUSTOM_FOOTER} where you want it in the template file.
Logged
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #7 on: October 28, 2003, 07:12:04 pm »

Thanks for your input.
I can't use echo, my footer is about 15-16 kB (right menu column with dynamic content like last news headlines and recent questions from my faq section etc. etc.)

I tried your way to solve my little problem, but with no success. Now it seems that my browser cannot load the page at all. It just freezes while trying to open the page :roll:
Code: [Select]
function pageheader($section, $meta = '')  
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;

if(empty($custom_header)){
require("/absolute/path/to/header.txt");
$custom_header = ob_get_contents();
ob_clean();
}
// Create Custom Footer
if(empty($custom_footer)){
require("/absolute/path/to/footer.txt");
$custom_footer = ob_get_contents();
ob_clean();
}

   header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
   user_save_profile();
                 
   $template_vars = array(
      '{LANG_DIR}' => $lang_text_dir,  
      '{TITLE}' => $CONFIG['gallery_name'].' - '.$section,
      '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
      '{META}' => $meta,
      '{GAL_NAME}' => $CONFIG['gallery_name'],
      '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],    
      '{MAIN_MENU}' => theme_main_menu(),
      '{ADMIN_MENU}' => theme_admin_mode_menu(),  
      '{CUSTOM_HEADER}' => $custom_header,
      '{CUSTOM_FOOTER}' => $custom_footer,
   );
   
   echo template_eval($template_header, $template_vars);  
}  
Is the above right?
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
How to include a custom footer?
« Reply #8 on: October 28, 2003, 08:08:40 pm »

There should not be a comma after the $custom_footer variable.  That tells PHP to expect another variable for the array.
Logged
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #9 on: October 28, 2003, 08:19:42 pm »

Yep, my mistake.
But that didn't fix the problem...

Any more ideas?
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
How to include a custom footer?
« Reply #10 on: October 28, 2003, 08:29:35 pm »

You might try a test by putting the path to the footer in place of the path of the header.  That would let you know if it is a problem with placement (It might be getting tucked in the table or something).

Also, you could forgoe the requiring business and read the file contents into the variable from the file.  

$original_handle = fopen("path/to/footer", "r");

while(!feof($original_handle)) {
        $buffer = fread($original_handle, 1024);
        $custom_footer .= $buffer;
}

fclose($original_handle);

Then you could print the contents of the file in a manner similar to the echo command,

print $custom_footer;

That would keep it dynamic while somewhat simplifying things.

You can always use the anycontent module, too.
Logged
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #11 on: October 28, 2003, 08:59:58 pm »

I thought I know PHP at least a little, but turns out I know nothing.

OK, the footer is FINALLY there (menu tables and stuff like that), but without any dynamic content. I can see my php statements on source code though, so it must be something obvious (for you, not for me  :wink: ). As I said before, I'm not a php-guru.

So I'm still in trouble.
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
How to include a custom footer?
« Reply #12 on: October 28, 2003, 10:20:07 pm »

Well of course you aren't getting dynamic statements if you're using php statements in that file.   :)

I was under the impression you were letting another program modify the contents of a text file.  Why are you naming all your php files with txt extensions?

Also, please post the contents of the footer file here.  That will give us a better idea of how you are trying to do this. (And no, I don't care that it's really long.)
Logged
&quot;Then, Fletch,&quot; that bright creature said to him, and the voice was very kind, &quot;let&#039;s begin with level flight . . . .&quot;

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

farmer

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
How to include a custom footer?
« Reply #13 on: October 28, 2003, 11:10:20 pm »

My footer is as follows (a bit simplified to save some space here):

Code: [Select]

<!-- END OF COPPERMINE  -->
</td>

<td width="140">

<!-- START RIGHT MENU  -->
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>
<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:1'0'_blank''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>

</td></tr>

<tr><td>
<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:2'0'_blank''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>

</td></tr>

<tr><td>
<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:3'0'_blank''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>

</td></tr>

<tr><td>
<?php 
include ('../shop/bestsellers.php');
include (
'../shop/specials.php');
include (
'../shop/new_stuff.php');
?>

</td></tr></table>

</td>

<!-- RIGHT MENU FINISH -->

</tr></table>

<!-- MAIN TABLE FINISH -->
</body>
</html>
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 19 queries.