coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: buddy0815 on January 06, 2012, 10:18:36 PM

Title: disable menu for guests
Post by: buddy0815 on January 06, 2012, 10:18:36 PM
Hi folks,

I whish to display all menu items just if the user is logged in. A guest does not need any menu items (because it's bridged to joomla and the joomla menu is enough)

I find out that this should be possible with the !USER_ID Flag. But where to place the if-command? in the theme.php?

Also it would be great if the hole div which contains the menu disappear when the user is not logged in so that there isn't an empty div on the page.

Can anyone help me with this?

Thanks in advance
Title: Re: disable menu for guests
Post by: Αndré on January 11, 2012, 12:41:16 PM
Please try if the FinalExtract plugin fits your needs. If not, please post a link to your gallery and describe what exactly has to be removed (really the whole menu, including the login / register buttons?).
Title: Re: disable menu for guests
Post by: buddy0815 on January 11, 2012, 09:36:36 PM
Thanks for your hint. Sounds great. Unfortunately I'm not able to install the plugin. It appears a button "install" but if I klick it, the page reloads and nothing else happens... Any Ideas? Would love to try that plugin.

And, to get back to your question. Yes, I'm trying to eliminate the whole menu when the user is not logged in. The cpg is bridged in a joomla page. Users have the joomla menu and can also log in via the joomla login field. After they are registered the cpg menu should appear.

Thanks and have a nice day
Title: Re: disable menu for guests
Post by: phill104 on January 11, 2012, 11:21:42 PM
The final extract should work. Try putting your cpg install into standalone mode first. Joomla uses Mootools while CPG uses jQuery and sometimes they conflict which may be why you are having trouble installing the plugin.
Title: Re: disable menu for guests
Post by: Αndré on January 12, 2012, 08:43:26 AM
Copy this to your theme's theme.php file:
/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
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']);

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    if (USER_ID) {
        $template_vars = array(
            '{LANG_DIR}' => $lang_text_dir,
            '{TITLE}' => theme_page_title($section),
            '{CHARSET}' => $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,
            '{JAVASCRIPT}' => theme_javascript_head(),
            '{MESSAGE_BLOCK}' => theme_display_message_block(),
        );
    } else {
        $template_vars = array(
            '{LANG_DIR}' => $lang_text_dir,
            '{TITLE}' => theme_page_title($section),
            '{CHARSET}' => $charset,
            '{META}' => $meta,
            '{GAL_NAME}' => $CONFIG['gallery_name'],
            '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
            '{SYS_MENU}' => '',
            '{SUB_MENU}' => '',
            '{ADMIN_MENU}' => theme_admin_mode_menu(),
            '{CUSTOM_HEADER}' => $custom_header,
            '{JAVASCRIPT}' => theme_javascript_head(),
            '{MESSAGE_BLOCK}' => theme_display_message_block(),
        );
    }
   
    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}
/******************************************************************************
** Section <<<pageheader>>> - END
******************************************************************************/
Title: Re: disable menu for guests
Post by: buddy0815 on January 15, 2012, 02:38:08 PM
@Phill, sorry even in the stand alone version, the installation of the plugin doesn't work. Clicking on the install button just let the page reload... nothing else seems to happen.

@André, thanks for the code. That works. Unfortunately the div in which the menu normally appears is still there. So there is a blank div if the user is not logged in.. So I get a step further but it's not solved anyway. Would be much better to make the whole div to disappear.

Nevertheless it will work for the first time.

Thanks to all