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: Customizing the template.html file.  (Read 3855 times)

0 Members and 1 Guest are viewing this topic.

gregblach

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Customizing the template.html file.
« on: June 26, 2005, 02:14:38 pm »

#1 -> Thanks for a great gallery script! Easy to install, easy to use, and works like a charme!  :D

#2 -> Being a novice in PHP, I am having difficulties understanding why the following is not working out for me:

I am using the water_drop template. My site is built of pretty static content, but still I have created a topmenu.php file, which obviously contains the top menu for all pages on my site. It is just a simple table with with internal links, and looks something like this:

Code: [Select]
<div align="center">
<table cellpadding="0" cellspacing="2">
  <tr>
    <td class="admin_menu" nowrap><a href="http://www.xxx.dk/hugin/" target="_self" title="xxx">xxx</a></td>
    <td class="admin_menu" nowrap><a href="http://www.xxx.dk/hugin/pics/" target="_self" title="xxx">xxx</a></td>
  </tr>
</table>
</div>

I then call the menu using require 'topmenu.php';.

To be able to do this with coppermine I started out by changing the filetype of the template.html to template.php, and modify the line define('TEMPLATE_FILE', 'template.php'); in the init.inc.php file. However, I am not getting the result I am looking for. I have tried so many different things to get this to work using PHP, but so far no luck.

Funny thing is that if I insert the html code directly from my topmenu script into the template.php page, it works.... ???

It is probably the simplest thing in the world to do this, I just can't figure out what I am missing.

Thanks in advance!  :)

/Greg
« Last Edit: June 27, 2005, 08:25:54 pm by gregblach »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Customizing the template.html file.
« Reply #1 on: June 26, 2005, 02:19:09 pm »

You can't change the filetype of template.html - it's just a file that is parsed and spit out, so includes and such don't work.  All custom php must be in the theme.php file.  Please search for custom header or read the FAQ.

http://coppermine.sourceforge.net/faq.php#customHeader
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

gregblach

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Customizing the template.html file.
« Reply #2 on: June 26, 2005, 03:17:11 pm »

Hi kegobeer. Thanks for the hint. I would have NEVER figured that out myself.  :-\\

I tried out the suggestions in my 133 installation and ended up with the following:

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir, $lang_default_font_size;

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

   if(empty($custom_header)){
      include('../../../topmenu.php');
      static $custom_header = ob_get_contents();
      ob_clean();

    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();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu()
        '{TOP_MENU}' => $custom_header,
        );

    echo template_eval($template_header, $template_vars);
}

In the template.html file I then inserted a {TOP_MENU} bit like so:

Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" align="center">
    {TOP_MENU}
    <h1>{GAL_NAME}</h1>
    <h3>{GAL_DESCRIPTION}</h3><br />
    {MAIN_MENU}<br />
    {LANGUAGE_SELECT_FLAGS}<br>{LANGUAGE_SELECT_LIST}&nbsp;
    {THEME_SELECT_LIST}
    </td>
  </tr>
</table>

Now when I try to go to my gallery I get a blank page, and when viewing the page source I get <html><body></body></html>, and that's it. I am still doing something wrong.  ???

/Greg
« Last Edit: June 26, 2005, 04:46:41 pm by kegobeer »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Customizing the template.html file.
« Reply #3 on: June 26, 2005, 04:51:37 pm »

I edited your previous post - please use the code format when you post code, not the bold format.

Post your topmenu.php file so we can see it.

If your top menu is just static html, why not just add that to your template.html file?  You don't need php unless your data is being dynamically generated.  Just put your top menu html in your template.html file wherever you want it.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

gregblach

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Customizing the template.html file.
« Reply #4 on: June 27, 2005, 08:31:10 pm »

Sure thing. Didn't notice the code tag before.

I have updated my first entry in this post. Here I have shown an example of the content in the topmenu.php file.

The reason I am using it, is that I have maybe 10 different subpages. Instead of having to update the menu in every single page, it would be more convinient for me to do it in just the topmenu.php file.

So, I would like to know how to do this for two reasons; First of all because I would like to get the code working, and secondly because this is  learning experience to me (and it might be helpful to others too).  :)

Best regards

Greg
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.