我使用名为“注销”的标准 joomla 用户菜单项为注销创建了一个菜单项。在菜单项中,它显示了这个链接:
index.php?option=com_users&view=login&layout=logout&task=user.menulogout
(注销重定向设置为链接到我域中的菜单项)
在
组件/com_users/controllers/user.php
我找到了这个:
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));
}
现在我尝试将我在 https://docs.joomla.org/Display_error_messages_and_notices/de上找到的消息代码
JFactory::getApplication()->enqueueMessage('Logout successful', 'message');
这个 menulogout() 代码中的几乎所有地方。但是我注销时永远不会显示消息。
有任何想法吗 ?