disable menu for guests disable menu for guests
 

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

disable menu for guests

Started by buddy0815, January 06, 2012, 10:18:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

buddy0815

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

Αndré

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?).

buddy0815

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

phill104

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.
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

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
******************************************************************************/

buddy0815

@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