How do I remove a button from the menu? How do I remove a button from the menu?
 

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

How do I remove a button from the menu?

Started by aibonlengket, December 17, 2005, 12:46:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aibonlengket

I hope I got the right place to ask this.

I have mambo 4.5.2.3 with cpg 1.4.2 integrated beautifully. I have it wraped in mambo. What I want to do is to erase the login/logout including the link in the cpg. It's in the {SYS_MENU} I think, if we are refering to the template. I did a hack in the /lang/english.php on line 128-131 to ignore it. It work, but when I log in there's a name of the user that have a link to take you to logut. because I have it wrapped in mambo, the frame takes you directly to the home page mambo; but still wrapped in the main mambo. can anybody help me please...

Joachim Müller

to edit a menu (or anything else), take a look at themes/sample/theme.php, find the menu section, copy it over to the theme you're actually using (themes/yourtheme/theme.php). Then edit the menu accordingly (comment the login link out, don't remove it). Another option would be to add a target attribute to the <a href> tag.

aibonlengket

Thanks GuGu. I got it to work. here's what I did. I copy everything in the /sample/theme.php to my theme /blackbirch/theme.php. edit the  /blackbirch/theme.php

from
   addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
   addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');

to
addbutton($sys_menu_buttons,'','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
addbutton($sys_menu_buttons,'','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');

is this what you ment by comment it out? and another thing is do you have to copy everything from the /sample/theme.php? because I saw on the other theme.php they just copy what was need. I tried to do that but I failed. I guess I don't understand what needed and whats not. can you give me a clue? Thanks for the fast reply.

oh one more thing. where do you put the <a href> tag? in the theme.php and replace {LOGIN_LNK}?

Joachim Müller

#3
you comment out stuff in php by putting two slashes in front of the code. To get rid of the login link, findaddbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');and replace with// addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
You're not meant to copy everything from the sample theme, but only the stuff you want changed.

tgontz

How do I remove the Login button from the menu? I have tried commenting it out, but depending on how I do the commenting out, my gallery will will either not load at all or I get the following error in Internet Explorer:

Template error
Failed to find block 'login'(#(<!-- BEGIN login -->)(.*?)(<!-- END login -->)#s) in :

I was successfully able to comment out some of the other menu items, but not the Login.

My gallery is located at is http://www.gontzphotography.com/gallery/index.php

I am using a custom theme I named classic_paypal and copied and pasted the menu code from the sample theme.

Thanks in advance!

artistsinhawaii

comment out what is BETWEEN the BEGIN and END markers.. do not comment out the markers themselves.

Quote
<!-- BEGIN login -->

// (.*?)        <!-- comment out what is here between the two markers -->

<!-- END login -->)


Dennis
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

tgontz

I am using 1.4.2 and do not have the markers. Am I looking in the wrong place?

This is what I have:

// HTML template for template sys_menu buttons
    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
   
    addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
    addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');
    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.

artistsinhawaii

OOps, sorry, I always do it using the old menu layout.
Don't know if this will work, but try blocking out the login/logout options and add

<!-- BEGIN login -->
<!-- END login -->)


just above     // Login and Logout don't have a spacer as only one is shown, and either would be the last option.

Dennis
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

tgontz

I got it now. I simply put // in front of the addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');

(Which I thought that I tried before and it wasn't working - I must have also been doing something else different!)

Also, by the way, when I tried to use any html comment tags <!-- --> my gallery would not load at all. I would just get a blank white browser window.

Thanks for the suggestions!

tgontz

Well I thought that I had this issue resolved. However, I just went to log in to my gallery and I got the following error:

Template error
Failed to find block 'login'(#(<!-- BEGIN login -->)(.*?)(<!-- END login -->)#s) in :
            <!-- BEGIN home -->
        <a href="{HOME_TGT}" title="{HOME_TITLE}">Gallery Home</a> ::
  <!-- END home -->  <!-- BEGIN my_gallery -->
        <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}">{MY_GAL_LNK}</a> ::
  <!-- END my_gallery -->  <!-- BEGIN allow_memberlist -->
        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}">{MEMBERLIST_LNK}</a> ::
  <!-- END allow_memberlist -->  <!-- BEGIN my_profile -->
        <a href="{MY_PROF_TGT}" title="{MY_PROF_TITLE}">{MY_PROF_LNK}</a> ::
  <!-- END my_profile -->  <!-- BEGIN enter_admin_mode -->
        <a href="{ADM_MODE_TGT}" title="{ADM_MODE_TITLE}">{ADM_MODE_LNK}</a> ::
  <!-- END enter_admin_mode -->  <!-- BEGIN leave_admin_mode -->
        <a href="{USR_MODE_TGT}" title="{USR_MODE_TITLE}">{USR_MODE_LNK}</a> ::
  <!-- END leave_admin_mode -->  <!-- BEGIN upload_pic -->
        <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}">{UPL_PIC_LNK}</a> ::
  <!-- END upload_pic -->  <!-- BEGIN register -->
        <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}">{REGISTER_LNK}</a> ::
  <!-- END register -->  <!-- BEGIN faq -->
        <a href="{FAQ_TGT}" title="{FAQ_TITLE}">{FAQ_LNK}</a> ::
  <!-- END faq -->  <!-- BEGIN logout -->
        <a href="{LOGOUT_TGT}" title="{LOGOUT_TITLE}">{LOGOUT_LNK}</a>
  <!-- END logout -->







This is what my theme.php file looks like:



<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly 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.2
  $Source: /cvsroot/coppermine/devel/themes/classic/theme.php,v $
  $Revision: 1.71 $
  $Author: gaugau $
  $Date: 2005/10/25 01:16:24 $
**********************************************/

// ------------------------------------------------------------------------- //
// This theme has all CORE items removed                                     //
// ------------------------------------------------------------------------- //
define('THEME_IS_XHTML10_TRANSITIONAL',1);

// Creates an array of tokens to be used with function assemble_template_buttons
// this function is used in this file it needs to be declared before being called.
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer) {
  $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer);
}


// HTML template for sys_menu
$template_sys_menu = <<<EOT
          {BUTTONS}
EOT;

// HTML template for sub_menu
$template_sub_menu = $template_sys_menu;


  // HTML template for template sys_menu spacer
  $template_sys_menu_spacer ="::";

  // HTML template for template sys_menu buttons
  $template_sys_menu_button = <<<EOT
  <!-- BEGIN {BLOCK_ID} -->
        <a href="{HREF_TGT}" title="{HREF_TITLE}">{HREF_LNK}</a> {SPACER}
  <!-- END {BLOCK_ID} -->
EOT;

  // HTML template for template sys_menu buttons
    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}

   
    addbutton($sys_menu_buttons,'Gallery Home','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
    //addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq',$template_sys_menu_spacer);
   

    //addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');


    addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');
    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.




  // HTML template for template sub_menu spacer
  $template_sub_menu_spacer = $template_sys_menu_spacer;

  // HTML template for template sub_menu buttons
  $template_sub_menu_button= $template_sys_menu_button;

  // HTML template for template sub_menu buttons
    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'Album View','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer);
    //addbutton($sub_menu_buttons,'{ALB_LIST_LNK}','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer);
/* //Commented out by Trevor
    addbutton($sub_menu_buttons,'{LASTUP_LNK}','{LASTUP_TITLE}','{LASTUP_TGT}','lastup',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{LASTCOM_LNK}','{LASTCOM_TITLE}','{LASTCOM_TGT}','lastcom',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sub_menu_spacer);
*/

    addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');
?>



Any suggestions?

donnoman

re-enable the items in sys_menu so we don't get template errors; we will strip the login and home links with a plugin

   addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);

   addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');



To remove the spacer after the FAQ link edit your buttons and replace the spacer variable.

    addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq','');
    addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
    addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');
    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.


Upload and enable the final_extract plugin.

final_extract codebase.php

$thisplugin->add_filter('page_html','final_extract_page_html');

function final_extract_block(&$template, $block_name, $subst='')
{
        $pattern = "#(<!-- BEGIN $block_name -->)(.*?)(<!-- END $block_name -->)#s";
        if ( preg_match($pattern, $template, $matches)){
            $template = str_replace($matches[1].$matches[2].$matches[3], $subst, $template);
            return $matches[2];
        }
}

function final_extract_page_html($html)
{   
    //repeat the next line for each block you would like removed
    final_extract_block($html, 'login');
    final_extract_block($html, 'home');
return $html;
}


tgontz

I'm not sure exactly what I am supposed to do with the final_extract.zip file. I extracted the this file so that codebase.php and configuration.php are in a final named final_extract on my desktop. I then searched the forum on to install a plugin. I found the following:

"Navigate to the pluginmgr.php page, click browse, locate the plugin you downloaded on your PC and click upload. Once the plugin has beploaded, click on the (i) icon to install it. Follow any setup instructions provided by the plugin's installer."

So I tried this for each file, but I get an error message saying, "The file uploaded is not a plugin package. "

I then tried to upload the zip file and I recieved the following error:"There was an error copying the package to the plugins folder."


What exactly am I to do with the information you posted?

Thank you!

donnoman

just use regular ftp to upload the final_extract folder to the plugins folder.

aibonlengket

thaks man it work like a charm. now I dont have to hack the template

tgontz

donnoman,

I want to thank you as well! The plugin works great!

donnoman


Linea

I don't want to remove the Login button, but the button "toprated" or "last commented" for example. This should work te same way, shouldn't it? So I copied the section

if (!defined('THEME_HAS_NO_SUB_MENU_BUTTONS')) {

  // HTML template for template sub_menu spacer
  $template_sub_menu_spacer = $template_sys_menu_spacer;

  // HTML template for template sub_menu buttons
  $template_sub_menu_button= $template_sys_menu_button;

  // HTML template for template sub_menu buttons
    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{ALB_LIST_LNK}','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer);
    //addbutton($sub_menu_buttons,'{LASTUP_LNK}','{LASTUP_TITLE}','{LASTUP_TGT}','lastup',$template_sub_menu_spacer);
    //addbutton($sub_menu_buttons,'{LASTCOM_LNK}','{LASTCOM_TITLE}','{LASTCOM_TGT}','lastcom',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');

  $params = array('{BUTTONS}' => assemble_template_buttons($template_sub_menu_button,$sub_menu_buttons));
  $template_sub_menu = template_eval($template_sub_menu,$params);
}

into my theme.php, but I get the following error: Fatal error: Call to undefined function: addbutton() in /var/www/vhosts/lalapanzi.de/httpdocs/fotogalerie/themes/galopprennen/theme.php on line 38

Undefined function? I just copied it from .../sample/theme.php. What's wrong with it?

Tranz

It means you need to copy the function over, too.

// Creates an array of tokens to be used with function assemble_template_buttons
// this function is used in this file it needs to be declared before being called.
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer) {
  $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer);
}

Tranz

You also needed to copy over this function:
// Creates buttons from a template using an array of tokens
// this function is used in this file it needs to be declared before being called.
function assemble_template_buttons($template_buttons,$buttons) {
    $counter=0;
    $output='';

    foreach ($buttons as $button)  {
      if (isset($button[4])) {
         $spacer=$button[4];
      } else {
      $spacer='';
      }

        $params = array(
            '{SPACER}'     => $spacer,
            '{BLOCK_ID}'   => $button[3],
            '{HREF_TGT}'   => $button[2],
            '{HREF_TITLE}' => $button[1],
            '{HREF_LNK}'   => $button[0]
            );
        $output.=template_eval($template_buttons, $params);
    }
    return $output;
}

Linea

Hey TranzNDance, thank you very much for your answer! Everything is a bit complicated in a foreign language. But this support forum is much better than the german one, so I try to find the solution here. :-) I understand what you say...before using "addbutton" I have to define it. OK! I will try after having finished work today.