Adding classname in Sysmenu and Submenu Adding classname in Sysmenu and Submenu
 

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

Adding classname in Sysmenu and Submenu

Started by manchumahara, August 31, 2008, 10:14:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

manchumahara

I was trying to make new theme but got some lack of class name in Sysmenu and Submenu. Actually I wanted this type of class name in menu link
<a class="button_home" title="Go to the home page" href="index.php">Home</a>

Look if there was classname like "button_home"  in each menu link then it's easy to apply custom image or style using css.
Then I tried to make this happen and I did it. Here is what I have done .

Open file galleryroot\include\themes.inc.php find function assemble_template_buttons and then find
    foreach ($buttons as $button)  {
      if (isset($button[4])) {
         $spacer=$button[4];
      } else {
      $spacer='';
      }


After that just add
     if (isset($button[5])) {
         $classname=$button[5];
      } else {
      $classname='';
      }


Now find    '{SPACER}'     => $spacer, and add the bellow line before this
'{CLASSNAME}' =>$classname,   


Find  function addbutton  and change the function like bellow

// 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.
if (!function_exists('addbutton')) {  //{THEMES}
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer[b],$classname[/b]) {
  $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer[b],$classname[/b]);
}
}  //{THEMES}


In the above code I have added the bold part to add a class name in menu link :D

Now find this line    "// HTML template for template sys_menu buttons"

and change code like bellow



  // HTML template for template sys_menu buttons
  if (!isset($template_sys_menu_button)) { //{THEMES}
  $template_sys_menu_button = <<<EOT
  <!-- BEGIN {BLOCK_ID} -->
        <a href="{HREF_TGT}" title="{HREF_TITLE}" [b]class="{CLASSNAME}"[/b]>{HREF_LNK}</a> {SPACER}
  <!-- END {BLOCK_ID} -->
EOT;
  } //{THEMES}


Here I have changed the bold part :D]

Now find with keyword  addbutton and check all the matchings.
You will get this type of lines


// HTML template for template sys_menu buttons
if (!isset($sys_menu_buttons)) { //{THEMES}
  // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
  addbutton($sys_menu_buttons,'{HOME_LNK}', '{HOME_TITLE}', '{HOME_TGT}', 'home', $template_sys_menu_spacer, 'button_home');
  addbutton($sys_menu_buttons,'{MY_GAL_LNK}', '{MY_GAL_TITLE}', '{MY_GAL_TGT}', 'my_gallery', $template_sys_menu_spacer,'button_mygallery');
  .
  .
  .
  addbutton($sys_menu_buttons, '{LOGIN_LNK}', '{LOGIN_TITLE}', '{LOGIN_TGT}', 'login','','button_login');
  addbutton($sys_menu_buttons, '{LOGOUT_LNK}', '{LOGOUT_TITLE}', '{LOGOUT_TGT}', 'logout', '','button_logout');
  // Login and Logout don't have a spacer as only one is shown, and either would be the last option.
} //{THEMES}


Here I have added the bold part for class name. Hope this will help you.

Don't hesitate to ask me if u are confued.

How can u add an image before a menu link
just add this type code in your style sheet. If class name of "Home" menu is "button_home" then
add new entry in css file like this
a.button_home{ background:url(images/icon_home.gif) left top no-repeat; padding-left:17px; padding-right:4px;}

Here icon_home.gif is image name that u have to put in "images" folder in the theme .


Thanks

Joachim Müller

Thanks for your readiness to share. This is not related to the modpack in itself, but applies to a "standard" coppermine install as well.
I suggest using the bbcode button [ c o d e ] more often in your postings. I partially edited your posting accordingly, although you make use of the bold button, so I can hardly use it throughout your posting.

manchumahara

Thank you Joachim Müller . Actually I am habitual with phpbb forum and in it bbcode buttons are well iconed. Sorry, next time I will post correctly.

If u think that the post is in wrong place then pls take it to relevant section.

Thanks