coppermine-gallery:Adding classname in Sysmenu and Submenu

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(&amp;amp;amp;$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 Cheesy

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 = <<
<!-- BEGIN {BLOCK_ID} -->
<a title="{HREF_TITLE}" href="{HREF_TGT}">{HREF_LNK}</a> {SPACER}
<!-- END {BLOCK_ID} -->
EOT;
} //{THEMES}

Here I have changed the bold part Cheesy]

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 .
My post in coppermine forum: line is here
Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *