How to include a custom footer? How to include a custom footer?
 

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

Main Menu

How to include a custom footer?

Started by farmer, October 27, 2003, 05:33:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

farmer

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!

DJMaze

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

Or the nicer approach:
Open theme.php and echo something above $template_footer
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

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

Joachim Müller

hm, did you insert your include statement right before (or after) 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

farmer

OK, this is what I have in theme.php:
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.

      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:

farmer

or maybe I have to add include ('/absolute/path/to/my/footer.txt'); manually to every .php file?

hyperion

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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

farmer

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

hyperion

There should not be a comma after the $custom_footer variable.  That tells PHP to expect another variable for the array.
&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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

farmer

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

Any more ideas?

hyperion

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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

farmer

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.

hyperion

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.)
&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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

farmer

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


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