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: Modifying SYS_MENU error  (Read 10401 times)

0 Members and 1 Guest are viewing this topic.

marvo

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Modifying SYS_MENU error
« on: May 13, 2006, 12:22:37 am »

I'm trying to edit the text and links for the buttons that appear tat the top of the gallery. However....all is not well. I've copied the following text from sample's theme.php and edited one button as a trial:

Quote
// 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;
}


// 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;

if (!defined('THEME_HAS_NO_SYS_MENU_BUTTONS')) {

  // 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,'Home Page','Home Page','../../../index.html','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.

  $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
  $template_sys_menu = template_eval($template_sys_menu,$params);
}

As far as I can make out, this should be fine but I'm still getting this error:
Quote
Template error
Failed to find block 'custom_link'(#(<!-- BEGIN custom_link -->)(.*?)(<!-- END custom_link -->)#s) in :

          {BUTTONS}

I've tried a number of variations but I'm getting no further. I'm using a customised Mac OX X theme and 1.4.5 which I've recently upgraded from 1.3.? I've read through the theme upgrade doc but I can't find anything that I thought was relevant to this i.e. had to be done in advance of this. Have I missed something?
« Last Edit: May 16, 2006, 01:27:55 am by Paver »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Modifying SYS_MENU error
« Reply #1 on: May 13, 2006, 12:34:36 am »

There's your problem - right there.  See it?    :)

You need to either:
  • Remove the line: $template_sub_menu = $template_sys_menu;
or
  • Copy the SUB_MENU customization block as well

The custom link is on the SUB_MENU and that one line starts the customization of the SUB_MENU but you left out the rest of that customization so Coppermine is not happy.  If you leave out that one line, Coppermine will use the default SUB_MENU.
Logged

marvo

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Modifying SYS_MENU error
« Reply #2 on: May 13, 2006, 12:59:54 am »

Thanks for the reply GauGau... you knew all along didn't  you  ::) I appreciate you bearing with me. No, I hadn't read the rules - simpy applied those from other boards I'm part of. I copied down from sample.php until I found the last lines. What I didn't realise was that there are two sets of those final lines and I only copied to the first set not the last. Could I humbly suggest that for dorks like me, something to this effect is added to that sticky you posted on doing this? It might save yourself fielding these kinds of errors again.

In answer to your question: no, I don't really see it unfortunately.

I was also confused (still am?) about what the SYS_MENU and SUB_MENU are. HERE's our gallery and it's those buttons along the top that I want to edit. I now think that that's the SUB_MENU, is that correct? Aarrrgghhh this was all so much easier for me in 1.3.x and I had it all set up fine until the upgrade!

I still get the same error so I must be doing something really obvious wrong despite having copied in and edited the SUB_MENU block. Here's the code so far:
Code: [Select]
// 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;
}


// 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;

if (!defined('THEME_HAS_NO_SYS_MENU_BUTTONS')) {

  // 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,'{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.

  $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
  $template_sys_menu = template_eval($template_sys_menu,$params);
}

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,'My Link','MY Title','www.mysite.co.uk','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);
}
Logged

Nibbler

  • Guest
Re: Modifying SYS_MENU error
« Reply #3 on: May 13, 2006, 01:14:52 am »

The sub menu is the main one along the top, and the sys menu is the one with Home and login. Also Paver is not GauGau ;)
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Modifying SYS_MENU error
« Reply #4 on: May 13, 2006, 01:26:41 am »

I'm not?  Huh.  That's an eye-opener.   ::)

@marvo: I just re-read your original post and realized you are using a customized Mac OSX theme.  You don't have to use the new addbutton() shortcuts with this theme.  If you look at the 1.4.5 Mac OSX theme, you'll see that the SYS_MENU and SUB_MENU are defined with straight HTML in the variables $template_sys_menu and $template_sub_menu.  Look at the 1.4.5 theme to see where your 1.3 buttons are, then split up your 1.3 buttons into the two new variables appropriately.  Or copy the variables from the 1.4.5 theme and modify it accordingly to your 1.3 theme.
Logged

marvo

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Modifying SYS_MENU error
« Reply #5 on: May 13, 2006, 05:10:22 am »

The sub menu is the main one along the top, and the sys menu is the one with Home and login. Also Paver is not GauGau ;)
oh gee... sorry... thanks EVERYONE then

I'll try your suggestions and let you know how it goes. No time today though...
Logged

marvo

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Modifying SYS_MENU error
« Reply #6 on: May 16, 2006, 12:59:31 am »

Guys that was the easiest ten mins I've had on coppermine in a few weeks. Thanks for re-reading my original post and spotting that Paver because it was a piece of cake to do and is now done!
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Modifying SYS_MENU error
« Reply #7 on: May 16, 2006, 01:27:45 am »

I'm glad to hear that.  You're welcome.

The new 1.4.x theme system has a lot of advantages over the previous one, but there is some learning involved.  The core themes are there as a guide for how to use the new system.
Logged

SaigonK

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 59
Re: Modifying SYS_MENU error
« Reply #8 on: February 28, 2009, 12:12:43 pm »

I know this thread is old but it is something close to what i need, I dont want to add a custom link but want to change where the login link on sys_menu points too. i cant seem to find that particular code anywhere.

in a nutshell i have an SSL cert, i am going to use both http and htpps, but I want users to logon using https, so i need to change the link they use to https instead of http, any pointers?

Nibbler

  • Guest
Re: Modifying SYS_MENU error
« Reply #9 on: February 28, 2009, 03:44:20 pm »

Set up a redirect. Much easier solution that modifying code.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Modifying SYS_MENU error
« Reply #10 on: March 01, 2009, 10:09:04 am »

I know this thread is old but it is something close to what i need
You should have started a thread of your own and should have posted a reference in that new thread to the old thread. Locking.
Logged
Pages: [1]   Go Up
 

Page created in 0.035 seconds with 20 queries.