Individual SYS_MENU & SUB_MENU Options Individual SYS_MENU & SUB_MENU Options
 

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

Individual SYS_MENU & SUB_MENU Options

Started by littlefixit, June 14, 2006, 09:23:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

littlefixit

Greetings and Salutations:

I have a question regarding the SYS_MENU and SUB_MENU "variables" that are called in the 'template.html' file.

For the template I am attempting to design, I am interested in separating each of the functions/buttons that are generated and displayed wherever {SYS_MENU} and {SUB_MENU} are used in the code. The reason I wish to do this is for more control over where things are put in my template.
If anyone has ever used phpBB, and experimented with its themes, they will understand what I am referring to.
In summary: I would like to know how (or at least, where to start looking) to separate both links and the text on the buttons into separate {tags} so that I can place them wherever I wish in the template. I would appreciate any assistance and/or direction in this matter.
Sincerely,
littlefixit
P.S. - My website can be viewed at http://www.galacticarmy.com/; the forums specifically at http://www.galacticarmy.com/forums/; and the gallery (Coppermine) can be viewed at http://www.galacticarmy.com/coppermine/. Thank you for your time.

Paver

You don't really need to hack SYS_MENU and SUB_MENU - instead you can use their code as an example to process the new tags you set up.

Look at the functions pageheader() and pagefooter() in themes/yourtheme/theme.php (copying them from the sample theme.php if your theme doesn't have them already).  Those 2 functions process tags before and after the {GALLERY} tag respectively.  Create new tags, put them in the appropriate function (or both if you want them processed anywhere in template.html), then put the appropriate code in to render those tags, using the SYS_MENU and SUB_MENU code as examples.

Once you have things set up, you'll probably remove {SYS_MENU} and {SUB_MENU} from template.html.  However, there are certain buttons that Coppermine requires to be present - you'll get a "Template error - failed to find block" error if Coppermine doesn't find them.  So make sure to render all the default buttons from SYS_MENU and SUB_MENU in your other tags.  If you don't want a button, please read the sticky thread in this forum regarding how to properly remove buttons and do the same for your new tags.

littlefixit

Greetings again, and Thank you, Paver, for your quick reply.

I have done as you suggested, and copied the missing function code from the Sample Theme to my own theme. However, I must again display how new I am to the coppermine modding process. I am uncertain of what I should do now, though. From what I gathered in Paver's previous post, the next step would be to duplicate the
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        );

    echo template_eval($template_header, $template_vars);
}

and modify it (and others) in some way to create new functions with the same buttons--so long as all buttons are used, thereby avoiding the issue with missing buttons.
I just wanted to clarify that I am not attempting to add new buttons, but single out the individual buttons on the default SYS_MENU and SUB_MENUs for placement within my existing code. Perhaps there is a tutorial or walkthrough already on modding one of these functions. Either way, thank you for your help thus far!
Sincerely,
-littlefixit

littlefixit

I apologize for this double post: but I believe I have found my solution in (of all places) the documentation. In my defense, I was under the impression I had reviewed the proper materials before registering and asking my question. In any event, the proper methods for individualizing the buttons on the SYS_MENU and SUB_MENU bars appear to be in this reference 'manual':
http://coppermine-gallery.net/demo/cpg14x/docs/theme/index.html
Please correct me if I am wrong, but the excerpts from the theme "hardwired" in the coding example seem to be exactly what I'm looking for (even if the overall color/image scheme is not.  :) ) In any event, If I am successful in this endeavor, I will do my best to post my solution as soon as it becomes known to me.
Sincerely,
-littlefixit

Paver

It is true that if you just want to create HTML code here & there, you can use one of the themes that use straight-HTML for the SYS_MENU & SUB_MENU as an example.  The new "addbutton()" themes just use shortcut functions to create the HTML.

If you want to try something simpler, see if this does what you want.

In function pageheader(), add these lines:
    // MOD - Process my custom button tags
    $template_sys_menu_copy = $template_vars['{SYS_MENU}'];
    $template_sub_menu_copy = $template_vars['{SUB_MENU}'];
    $template_vars['{MYBUTTON_MYGALLERY}'] = template_extract_block($template_sys_menu_copy, 'my_gallery');
    $template_vars['{MYBUTTON_MEMBERLIST}'] = template_extract_block($template_sys_menu_copy, 'allow_memberlist');
    $template_vars['{MYBUTTON_LASTUP}'] = template_extract_block($template_sub_menu_copy, 'lastup');
    // MOD - END

just before the last line in the function:
    echo template_eval($template_header, $template_vars);

Then put {MYBUTTON_MYGALLERY}, {MYBUTTON_MEMBERLIST}, and {MYBUTTON_LASTUP} wherever you want in the page header section of template.html (before the {GALLERY} tag).  I used "MYBUTTON_" as the prefix to make it clear what new tags you are adding.  You can pull other buttons from the SYS_MENU and SUB_MENU by adding lines like this:
$template_vars['{MYBUTTON_LASTUP}'] = template_extract_block($template_sub_menu_copy, 'lastup');
where you can see that {MYBUTTON_LASTUP} is the tag to process from template.html, $template_sub_menu is the place where you find the LASTUP button, and 'lastup' is the block-id (look at the sys_menu and sub_menu to find the block IDs).

The spacers will show up when you do this, but if you're not using SYS_MENU and SUB_MENU, you can make the spacer blank, or if you are, you can strip it off as you like.

To process tags in pagefooter(), you merely have to modify the first two code lines above as shown:
    $template_sys_menu_copy = theme_main_menu('sys_menu');
    $template_sub_menu_copy = theme_main_menu('sub_menu');

littlefixit

I'm grateful you posted your tutorial. As it turned out, I needed it after all. (But I'm sure you knew that would be the case, or you wouldn't have posted such a helpful--and understandable--tutorial). Many thanks. However, the technique you suggested does not seem to work for the more dynamic functions, such as "login". I keep getting the following message:
QuoteTemplate error
Failed to find block 'login'(#(<!-- BEGIN login -->)(.*?)(<!-- END login -->)#s) in :

              <!-- BEGIN album_list -->
        <a href="index.php?cat=0" title="Go to the album list">Album list</a> ::
  <!-- END album_list -->  <!-- BEGIN lastup -->
        <a href="thumbnails.php?album=lastup&amp;cat=0" title="Show most recent uploads">Last uploads</a> ::
  <!-- END lastup -->  <!-- BEGIN lastcom -->
        <a href="thumbnails.php?album=lastcom&amp;cat=0" title="Show most recent comments">Last comments</a> ::
  <!-- END lastcom -->  <!-- BEGIN topn -->
        <a href="thumbnails.php?album=topn&amp;cat=0" title="Show most viewed items">Most viewed</a> ::
  <!-- END topn -->  <!-- BEGIN toprated -->
        <a href="thumbnails.php?album=toprated&amp;cat=0" title="Show top rated items">Top rated</a> ::
  <!-- END toprated -->  <!-- BEGIN favpics -->
        <a href="thumbnails.php?album=favpics" title="Go to my favorites">My Favorites</a> ::
  <!-- END favpics -->  <!-- BEGIN search -->
        <a href="search.php" title="Search the gallery">Search</a>
  <!-- END search -->
Based on this, or at least the "failed to find" portion at the top, I'm assuming that it means there is something not being called properly in order to display the full dynamic of the login/logout button (namely the text, or username that is displayed--i.e. logout [ littlefixit ], etc.--and so forth.) I would appreciate any further insight into this matter anyone can offer; and I especially thank you, Paver, for your assistance thus far.
I will continue to search the forums for information pertaining to this issue, but thought you deserved an update.
Sincerely,
-littlefixit

Paver

Yeah, that's my fault.  I was sloppy in my code.

Add this function to themes/yourtheme/theme.php (anywhere but make sure it's in a valid place, i.e. not inside another function - it's easiest to add it at the end, before the last line "?>"):
function template_get_block($template, $block_name)
{
        $pattern = "#(<!-- BEGIN $block_name -->)(.*?)(<!-- END $block_name -->)#s";
        if ( !preg_match($pattern, $template, $matches)){
                return '';
        }
        return $matches[2];
}


Then replace all the mentions in my mod code of template_extract_block with template_get_block.  Then you can use any block ID you want.  (I think.)

littlefixit

Genious. Absolute Genious, Paver. Thank you for your help.
$query = "SELECT karma FROM users WHERE username = 'Paver'";
$karma = $mysql_query($query);
$karma++;
;)
Just a little bit o' fun.
The only one I'm having difficulty isolating is the 'login' button. It simply doesn't appear. This is likely because I'm calling it the wrong name in the mod you wrote for me:
    // MOD - Process my custom button tags - Inspired/Written by Paver (CPG Support Forums)
    $template_sys_menu_copy = $template_vars['{SYS_MENU}'];
    $template_sub_menu_copy = $template_vars['{SUB_MENU}'];
    $template_vars['{MYBUTTON_HOME}'] = template_get_block($template_sys_menu_copy, 'home');
    $template_vars['{MYBUTTON_REGISTER}'] = template_get_block($template_sys_menu_copy, 'register');
    $template_vars['{MYBUTTON_LOGIN}'] = template_get_block($template_sub_menu_copy, 'login');
// REFERENCE LINK >> http://forum.coppermine-gallery.net/index.php?topic=32689.0;topicseen
    // MOD - END

Perhaps you could direct me to the function or .php document where all of these are declared so that I can find the names for myself in the future? That is, of course, unless there is some bit of magic I'm not aware of pertaining to the login/logout toggle. At this point in time I believe it prudent to inform you that I am using a bridged version of Coppermine, it is bridged with my phpBB at http://www.galacticarmy.com/forums/. I hope this helps. Thank you again for your time.
Sincerely,
-littlefixit

Paver

The block ID 'login' (and 'logout') is defined in SYS_MENU, so you have to use $template_sys_menu_copy.

Take a look at your theme's $template_sys_menu and $template_sub_menu, usually defined near the beginning theme.php.  If not defined there, then look at the sample theme's theme.php.