0

i created a menu item for the logout using a standard joomla user menu item named "Logout". In the menu item it shows me this link:

index.php?option=com_users&view=login&layout=logout&task=user.menulogout

(the logout redirect is set to link to a menu item within my domain)

in

components/com_users/controllers/user.php

I found this:

public function menulogout()
{
    // Get the ItemID of the page to redirect after logout
    $app    = JFactory::getApplication();
    $itemid = $app->getMenu()->getActive()->params->get('logout');

    // Get the language of the page when multilang is on
    if (JLanguageMultilang::isEnabled())
    {
        if ($itemid)
        {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true)
                ->select('language')
                ->from($db->quoteName('#__menu'))
                ->where('client_id = 0')
                ->where('id =' . $itemid);

            $db->setQuery($query);

            try
            {
                $language = $db->loadResult();
            }
            catch (RuntimeException $e)
            {
                return;
            }

            if ($language !== '*')
            {
                $lang = '&lang=' . $language;
            }
            else
            {
                $lang = '';
            }

            // URL to redirect after logout
            $url = 'index.php?Itemid=' . $itemid . $lang;
        }
        else
        {
            // Logout is set to default. Get the home page ItemID
            $lang_code = $app->input->cookie->getString(JApplicationHelper::getHash('language'));
            $item      = $app->getMenu()->getDefault($lang_code);
            $itemid    = $item->id;

            // Redirect to Home page after logout
            $url = 'index.php?Itemid=' . $itemid;
        }
    }
    else
    {
        // URL to redirect after logout, default page if no ItemID is set
        $url = $itemid ? 'index.php?Itemid=' . $itemid : JUri::root();
    }

    // Logout and redirect
    $this->setRedirect('index.php?option=com_users&task=user.logout&' . JSession::getFormToken() . '=1&return=' . base64_encode($url));

}

now I tried placing the message code I found on https://docs.joomla.org/Display_error_messages_and_notices/de

JFactory::getApplication()->enqueueMessage('Logout successful', 'message');

almost everywhere within this menulogout() code. But never is the message shown when I logout.

Any ideas ?

Maiky
  • 1
  • 2
  • This link may help https://stackoverflow.com/questions/21980142/joomla-logout-with-message. But as far as possible dont manipulate any core files. Hundreds of plugins are available to do the same task. – Amit Ray May 16 '20 at 13:24
  • @AmitRay thanks. I installed the plugin but neither with the original code nor with the altered code from the other post a receive a message when I log out. – Maiky May 17 '20 at 09:37

0 Answers0