New System Menu Button - Rainy Day Theme New System Menu Button - Rainy Day Theme
 

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

New System Menu Button - Rainy Day Theme

Started by othersi, February 02, 2007, 08:01:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

othersi

Hi folks.

I've read through the FAQ about adding links/buttons to the menu... I've tried to decipher the instructions, but I've failed.  It seems to require more understanding of coding than I have... or I'm just not grasping the instructions.

What I'm trying to do is add an extra button on the upper system menu.

I understand the use of the Custom Link option in the config, but that isn't what I need.

I've managed to get the button/link created, but to do so, the only way I could make sense of, was to edit the themes.inc.php file.

I just added a line:

addbutton($sys_menu_buttons,'Forum','SI Forum','http://www.othersi.com/index.php?action=forum','custom1',$template_sys_menu_spacer);

in the midst of that files "// HTML template for template sys_menu buttons" section.

It is working... but in my search for the method to do this, I've read a lot of advice to NOT edit the themes.inc.php file.

So... wanting to do things the right way, I went back to editing the rainy_day/theme.php file.

But, in this theme, the theme.php file doesn't include the "// HTML template for template sys_menu buttons section" ... well... it does, but it doesn't contain the 'addbutton' code.... just a small block which says:

EOT;

// HTML template for template sys_menu buttons
$template_sys_menu_button = <<<EOT
<!-- BEGIN {BLOCK_ID} -->
  <td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
  <td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
  <td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
          <a href="{HREF_TGT}" title="{HREF_TITLE}">{HREF_LNK}</a>
  </td>
  <td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>
<!-- END {BLOCK_ID} -->
EOT;



I tried copying the sys_menu button "addbutton($sys_menu_buttons....." stuff from the sample theme.php file into the rainy_day theme.php button... but I got parse errors.

I tried opening another themes (hardwired) theme.php file, and saw it was coded in a different way again, with <!-- BEGIN home -->, <!-- END home -->, <!-- BEGIN my_gallery -->, <!-- END my_gallery -->, etc coded.

I copied THAT and pasted it into the rainy_day theme.php file, editing the urls to the proper theme images, and it made didn't give me parse errors, but instead created somewhat broken buttons, and many, many copies of them... there was rows and rows of duplicate buttons.

I read in the FAQ that a plugin would be the best way to go, but then gave an example of coding that alters the admin menu... which isn't what I'm after.

So... I'm stumped.

If someone could show me the proper coding to put into the rainy_day theme.php file, that'd be great.

All I want is the standard buttons in the upper system menu, but with an extra, custom button just to the right of the home button.

You can see the result I'm looking for here:  http://www.othersi.com/gallery/

This was achieved by editing the themes.inc.php file... which, again, I understand is a bad idea... so want to know how to do it "properly"

Thanks in advance. 

othersi


Nibbler

I'd add it into the sys menu manually, like this:


// HTML template for sys_menu
// HTML template for sys_menu
$template_sys_menu = <<<EOT
  <div class="topmenu">
          <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
  {BUTTONS}
<td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
<td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
<td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
<a href="http://www.othersi.com/index.php?action=forum" title="SI Forum">Forum</a>
</td>
<td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>
                  </tr>
          </table>
  </div>
EOT;

othersi

Thanks.

Not entirely sure if I've understood your instruction... wasn't sure if I should replace some of the existing code with what you gave, or actually just add it.

What I have now is:

// HTML template for template sys_menu buttons
$template_sys_menu_button = <<<EOT
<!-- BEGIN {BLOCK_ID} -->
  <td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
  <td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
  <td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
          <a href="{HREF_TGT}" title="{HREF_TITLE}">{HREF_LNK}</a>
  </td>
  <td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>
<!-- END {BLOCK_ID} -->
EOT;

$template_sys_menu = <<<EOT
  <div class="topmenu">
          <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
                 
                  <td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
<td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
<td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
<a href="http://www.othersi.com/index.php?action=forum" title="SI Forum">Forum</a>
</td>
<td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>

  {BUTTONS}

                  </tr>
          </table>
  </div>
EOT;


And this is working, except for a very minor issue.  The FORUM button appears to the far left, while I'd prefer it in the 2nd position.


othersi

Oops.... sorry, I spoke too soon.

The above code has caused the FORUM button to appear in both the top menu (with Home, My gallery, etc) and the lower menu (with Album List, Last Uploads, etc).

Can be seen here:  http://www.othersi.com/gallery/index.php

othersi

Oh man... wish I could edit my posts. lol

I realized I had pasted in your code to the wrong section of my file.

I've "fixed" it... here is my current code for rainy_day/theme.php... the entire file:

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.10
  $Source$
  $Revision: 3275 $
  $Author: gaugau $
  $Date: 2006-09-03 12:10:47 +0200 (So, 03 Sep 2006) $
**********************************************/

// ------------------------------------------------------------------------- //
// This theme has had all redundant CORE items removed                           //
// ------------------------------------------------------------------------- //

define('THEME_HAS_RATING_GRAPHICS'1);
define('THEME_IS_XHTML10_TRANSITIONAL',1);


// HTML template for sys_menu
// HTML template for sys_menu
$template_sys_menu = <<<EOT
  <div class="topmenu">
          <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
  
<td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
<td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
<td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
<a href="http://www.othersi.com/index.php?action=forum" title="SI Forum">Forum</a>
</td>
<td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>

{BUTTONS}
                  </tr>
          </table>
  </div>
EOT;

// HTML template for template sys_menu buttons
$template_sys_menu_button = <<<EOT
<!-- BEGIN {BLOCK_ID} -->
  <td><img src="images/spacer.gif" width="5" height="25" border="0" alt="" /></td>
  <td><img src="themes/rainy_day/images/button1_r1_c1.gif" width="5" height="25" border="0" alt="" /></td>
  <td style="background-image:url(themes/rainy_day/images/button1_r1_c2.gif)">
          <a href="{HREF_TGT}" title="{HREF_TITLE}">{HREF_LNK}</a>
  </td>
  <td><img src="themes/rainy_day/images/button1_r1_c3.gif" width="5" height="25" border="0" alt="" /></td>
<!-- END {BLOCK_ID} -->
EOT;



?>



The result is still the same, however... the FORUM button is at the far left (would prefer it in position 2... this isn't a big deal though), and there is TWO copies of the FORUM button, in the upper, and lower menu.... I want it just in the top menu.


Nibbler

Add some more code :)


$template_sub_menu = <<<EOT
  <div class="topmenu">
          <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
  {BUTTONS}
                  </tr>
          </table>
  </div>
EOT;


There might be a better way than this, I'm not an expert on the theme system.

othersi

Thank you, that removed the button from the sub-menu.  :)