coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: hydroplane on October 09, 2006, 10:52:18 PM

Title: Separate menu items
Post by: hydroplane on October 09, 2006, 10:52:18 PM
Hi!
I'm using the classic template and I've just added a sidebar on the left of my gallery. What I'm trying to do is to move some buttons of the menu and the admin menu there.
'Log-in, most viewed, top rated, my favorites, search, download' should go inside the sidebar whereas album list, last uploads, last comments should stay in their default position.
How do I do that? I searched the board but with no luck.
Title: Re: Separate menu items
Post by: Joachim Müller on October 10, 2006, 08:15:01 AM
Depends on the setup of your "sidebar". Posting a link to your coppermine-driven page might be a good start.
Title: Re: Separate menu items
Post by: hydroplane on October 10, 2006, 10:07:42 AM
http://www.gsrfan.com/gallery/index.php
The only file I edited is template.html, I'm attaching it to this post.
Title: Re: Separate menu items
Post by: hydroplane on October 14, 2006, 10:36:00 PM
Just to give a better idea, this (http://img172.imageshack.us/img172/7373/galleryvq1.jpg) is what I'm trying to do. Anyone?
Title: Re: Separate menu items
Post by: Joachim Müller on October 15, 2006, 07:33:37 PM
After all, this issue is nearly identical to your other open thread: http://forum.coppermine-gallery.net/index.php?topic=37311.0

Anyway, just move the tokens in curly brackets where you want them:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<meta http-equiv="Pragma" content="no-cache" />
<title>{TITLE}</title>
{META}
<link rel="stylesheet" href="themes/classic/style.css" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
<!-- $Id: template.html 2688 2005-12-04 03:22:35Z donnoman $ -->
</head>
<body> {CUSTOM_HEADER}
<table width="100%" border="0" cellpadding="20" cellspacing="20">
<tr>
<! -- SIDEBAR -->
<td width="200" valign="top" style="border: 1px solid #666666;background-color:#FFFFFF;">
<table cellspacing="0" cellpadding="4" height="100%" width="100%" style="background-color: #CCCCCC">
<tr>
<td>{SYS_MENU} <br /> {SUB_MENU}</td>
<tr>
</table>
</td>
<! -- SIDEBAR END -->
<td valign="top" style="border: 1px solid #666666;background-color:#FFFFFF;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">{LANGUAGE_SELECT_FLAGS}</td>
</tr>
<tr>
<td align="center" valign="top">{THEME_SELECT_LIST} {LANGUAGE_SELECT_LIST}</td>
</tr>
</table>
<img src="images/spacer.gif" width="1" height="15" alt="" /><br />
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">{ADMIN_MENU} {GALLERY}</td>
</tr>
</table>
</td>
</tr>
</table>
{CUSTOM_FOOTER}{VANITY}
</body>
</html>
Will move the menus in question to your sidebar. You'll need to edit theme.php as well if you want a vertical menu.
Title: Re: Separate menu items
Post by: hydroplane on October 15, 2006, 08:33:18 PM
Ok, thanks. But how do I move only certain items?
Moving the sys_menu or the sub_menu tokens will change the position of the menu as a whole...I'd like to be able to split it and change the position of just some of the items. Is it possible?
Title: Re: Separate menu items
Post by: Joachim Müller on October 16, 2006, 05:00:49 AM
Well, then move the sys_menu only and leave the sub_menu where it used to be (or vice versa). Then edit the content of both menus by editing theme.php
Title: Re: Separate menu items
Post by: hydroplane on October 16, 2006, 10:45:09 PM
What's the right code to put into theme.php?
I tried editing the sub_menu first but all I could do was add/remove items, I wasn't able to move them separately.
I haven't found a tutorial anywhere so I took a look at the code of all the premade themes but there's no such thing as a split menu for any of them. :-\

Title: Re: Separate menu items
Post by: Joachim Müller on October 17, 2006, 07:38:23 AM
Did you look at above code and how I changed things? Just move one placeholder token then, leaving the other where it used to be, like this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<meta http-equiv="Pragma" content="no-cache" />
<title>{TITLE}</title>
{META}
<link rel="stylesheet" href="themes/classic/style.css" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
<!-- $Id: template.html 2688 2005-12-04 03:22:35Z donnoman $ -->
</head>
<body> {CUSTOM_HEADER}
<table width="100%" border="0" cellpadding="20" cellspacing="20">
<tr>
<! -- SIDEBAR -->
<td width="200" valign="top" style="border: 1px solid #666666;background-color:#FFFFFF;">
<table cellspacing="0" cellpadding="4" height="100%" width="100%" style="background-color: #CCCCCC">
<tr>
<td>{SYS_MENU}</td>
<tr>
</table>
</td>
<! -- SIDEBAR END -->
<td valign="top" style="border: 1px solid #666666;background-color:#FFFFFF;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">{LANGUAGE_SELECT_FLAGS}</td>
</tr>
<tr>
<td align="center" valign="top">{THEME_SELECT_LIST} {LANGUAGE_SELECT_LIST}</td>
</tr>
<tr>
<td align="center" valign="top">
{SUB_MENU}
</td>
</tr>
</table>
<img src="images/spacer.gif" width="1" height="15" alt="" /><br />
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">{ADMIN_MENU} {GALLERY}</td>
</tr>
</table>
</td>
</tr>
</table>
{CUSTOM_FOOTER}{VANITY}
</body>
</html>
An example for a split menu is Blix (http://coppermine-gallery.net/demo/cpg14x/index.php?theme=blix)
Title: Re: Separate menu items
Post by: hydroplane on October 17, 2006, 11:30:23 AM
I think I confused you. :)
Let's pretend I got rid of the SYS_MENU token and consider for a moment the SUB_MENU token only.
Blix has a vertical menu but all the items are still viewed as a group. Let's say for example I want to move the menu at the bottom of the page...what I have to do is move the SUB_MENU token at the bottom of the page accordingly.
And this is what I will see "Album list, Last uploads, Last comments, Most viewed, Top rated, My Favorites, Search".

But what if I want "Album list, Last uploads, Last comments" to be at the top of the page and "Most viewed, Top rated, My Favorites, Search" at the bottom? This is what I meant with 'split items'. :)

Title: Re: Separate menu items
Post by: Sami on October 17, 2006, 01:24:30 PM
Then you need to exchange links between $sys_menu_buttons and $sub_menu_buttons variables
Title: Re: Separate menu items
Post by: hydroplane on October 17, 2006, 03:35:07 PM
Almost there. I modified the links in theme.php, they're now inside the sidebar but I'm clearly doing something wrong because the links text show up as 'TOPN_LNK, TOPRATED_LNK, FAV_LNK, SEARCH_LNK', same for the url (site.com/gallery/TOPN_LNK) :-[
// 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.


// added from sub_menu to sys_menu
addbutton($sys_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sys_menu_spacer);
addbutton($sys_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sys_menu_spacer);
addbutton($sys_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sys_menu_spacer);
addbutton($sys_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');


$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,'{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);

// moved to sys_menu
// 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);
}
Title: Re: Separate menu items
Post by: Sami on October 17, 2006, 06:15:29 PM
You should also change theme_main_menu function
Copy it from themes/sample/theme.php to your theme.php and then define those placeholders on the actual $params
for example if you want My Favorites link to be under sys menu you should put {FAV_LNK},{FAV_TITLE},{FAV_TGT} place holders to sys menu $params array instead
Let me know if it's not clear ...
Title: Re: Separate menu items
Post by: hydroplane on October 17, 2006, 08:35:37 PM
It works now! Thanks a lot Sami. :D
I'm posting this last bit of code for future reference. // Function for creating a main menu (SYS_MENU or SUB_MENU)
function theme_main_menu($which)
{
    global $AUTHORIZED, $CONFIG, $album, $actual_cat, $cat, $REFERER;
    global $lang_main_menu, $template_sys_menu, $template_sub_menu;


    static $sys_menu = '', $sub_menu = '';
    if ($$which != '') {
        return $$which;
    }

    $album_l = isset($album) ? "?album=$album" : '';
    $cat_l = (isset($actual_cat))? "?cat=$actual_cat" : (isset($cat) ? "?cat=$cat" : '');
    $cat_l2 = isset($cat) ? "&amp;cat=$cat" : '';
    $my_gallery_id = FIRST_USER_CAT + USER_ID;



  if ($which == 'sys_menu' ) {
    if (USER_ID) {
        template_extract_block($template_sys_menu, 'login');
    } else {
        template_extract_block($template_sys_menu, 'logout');
        template_extract_block($template_sys_menu, 'my_profile');
    }

    if (!USER_IS_ADMIN) {
        template_extract_block($template_sys_menu, 'enter_admin_mode');
        template_extract_block($template_sys_menu, 'leave_admin_mode');
    } else {
        if (GALLERY_ADMIN_MODE) {
            template_extract_block($template_sys_menu, 'enter_admin_mode');
        } else {
            template_extract_block($template_sys_menu, 'leave_admin_mode');
        }
    }

    if (!USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_sys_menu, 'my_gallery');
    }

    if (USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_sys_menu, 'my_profile');
    }

    if (!USER_CAN_UPLOAD_PICTURES) {
        template_extract_block($template_sys_menu, 'upload_pic');
    }

    if (USER_ID || !$CONFIG['allow_user_registration']) {
        template_extract_block($template_sys_menu, 'register');
    }

    if (!USER_ID || !$CONFIG['allow_memberlist']) {
        template_extract_block($template_sys_menu, 'allow_memberlist');
    }

    if (!$CONFIG['display_faq']) {
        template_extract_block($template_sys_menu, 'faq');
    }

    $param = array(
        '{HOME_TGT}' => $CONFIG['home_target'],
        '{HOME_TITLE}' => $lang_main_menu['home_title'],
        '{HOME_LNK}' => $lang_main_menu['home_lnk'],
        '{MY_GAL_TGT}' => "index.php?cat=$my_gallery_id",
        '{MY_GAL_TITLE}' => $lang_main_menu['my_gal_title'],
        '{MY_GAL_LNK}' => $lang_main_menu['my_gal_lnk'],
        '{MEMBERLIST_TGT}' => "usermgr.php",
        '{MEMBERLIST_TITLE}' => $lang_main_menu['memberlist_title'],
        '{MEMBERLIST_LNK}' => $lang_main_menu['memberlist_lnk'],
        '{MY_PROF_TGT}' => "profile.php?op=edit_profile",
        '{MY_PROF_TITLE}' => $lang_main_menu['my_prof_title'],
        '{MY_PROF_LNK}' => $lang_main_menu['my_prof_lnk'],
        '{ADM_MODE_TGT}' => "mode.php?admin_mode=1&amp;referer=$REFERER",
        '{ADM_MODE_TITLE}' => $lang_main_menu['adm_mode_title'],
        '{ADM_MODE_LNK}' => $lang_main_menu['adm_mode_lnk'],
        '{USR_MODE_TGT}' => "mode.php?admin_mode=0&amp;referer=$REFERER",
        '{USR_MODE_TITLE}' => $lang_main_menu['usr_mode_title'],
        '{USR_MODE_LNK}' => $lang_main_menu['usr_mode_lnk'],
        '{UPL_PIC_TGT}' => "upload.php",
        '{UPL_PIC_TITLE}' => $lang_main_menu['upload_pic_title'],
        '{UPL_PIC_LNK}' => $lang_main_menu['upload_pic_lnk'],
        '{REGISTER_TGT}' => "register.php",
        '{REGISTER_TITLE}' => $lang_main_menu['register_title'],
        '{REGISTER_LNK}' => $lang_main_menu['register_lnk'],
        '{LOGIN_TGT}' => "login.php?referer=$REFERER",
        '{LOGIN_TITLE}' => $lang_main_menu['login_title'],
        '{LOGIN_LNK}' => $lang_main_menu['login_lnk'],
        '{LOGOUT_TGT}' => "logout.php?referer=$REFERER",
        '{LOGOUT_TITLE}' => $lang_main_menu['logout_title'],
        '{LOGOUT_LNK}' => $lang_main_menu['logout_lnk'] . " [" . stripslashes(USER_NAME) . "]",
        '{FAQ_TGT}' => "faq.php",
        '{FAQ_TITLE}' => $lang_main_menu['faq_title'],
        '{FAQ_LNK}' => $lang_main_menu['faq_lnk'],
// items moved from sub_menu
        '{TOPN_LNK}' => $lang_main_menu['topn_lnk'],
        '{TOPRATED_TGT}' => "thumbnails.php?album=toprated$cat_l2",
        '{TOPRATED_TITLE}' => $lang_main_menu['toprated_title'],
        '{TOPRATED_LNK}' => $lang_main_menu['toprated_lnk'],
        '{FAV_TGT}' => "thumbnails.php?album=favpics",
        '{FAV_TITLE}' => $lang_main_menu['fav_title'],
        '{FAV_LNK}' => $lang_main_menu['fav_lnk'],
        '{SEARCH_TGT}' => "search.php",
        '{SEARCH_TITLE}' => $lang_main_menu['search_title'],
        '{SEARCH_LNK}' => $lang_main_menu['search_lnk'],
        );

        $sys_menu = template_eval($template_sys_menu, $param);


  } else {

    if (!$CONFIG['custom_lnk_url']) {
        template_extract_block($template_sub_menu, 'custom_link');
    }

    $param = array(
        '{ALB_LIST_TGT}' => "index.php$cat_l",
        '{ALB_LIST_TITLE}' => $lang_main_menu['alb_list_title'],
        '{ALB_LIST_LNK}' => $lang_main_menu['alb_list_lnk'],
        '{CUSTOM_LNK_TGT}' => $CONFIG['custom_lnk_url'],
        '{CUSTOM_LNK_TITLE}' => $CONFIG['custom_lnk_name'],
        '{CUSTOM_LNK_LNK}' => $CONFIG['custom_lnk_name'],
        '{LASTUP_TGT}' => "thumbnails.php?album=lastup$cat_l2",
        '{LASTUP_TITLE}' => $lang_main_menu['lastup_title'],
        '{LASTUP_LNK}' => $lang_main_menu['lastup_lnk'],
        '{LASTCOM_TGT}' => "thumbnails.php?album=lastcom$cat_l2",
        '{LASTCOM_TITLE}' => $lang_main_menu['lastcom_title'],
        '{LASTCOM_LNK}' => $lang_main_menu['lastcom_lnk'],
        '{TOPN_TGT}' => "thumbnails.php?album=topn$cat_l2",
        '{TOPN_TITLE}' => $lang_main_menu['topn_title'],
        );


    $sub_menu = template_eval($template_sub_menu, $param);
  }



    return $$which;
}

?>