我正在使用 Joomla 3 构建一个站点,并希望在每个唯一用户从主页登录时将其重定向到特定页面。例如,当他们在登录表单中输入他们的详细信息并单击提交时,它会将他们重定向到带有 URL index.php/用户名的页面
我找到了mod_login/helper.php文件,但我不知道如何编辑它。
如何使用 PHP 将它们重定向到特定页面?
以下代码为mod_login/helper.php文件
<?php
/**
* @package Joomla.Site
* @subpackage mod_login
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper for mod_login
*
* @package Joomla.Site
* @subpackage mod_login
* @since 1.5
*/
class ModLoginHelper
{
public static function getReturnURL($params, $type)
{
$app = JFactory::getApplication();
$router = $app->getRouter();
$url = null;
if ($itemid = $params->get($type))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('link'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('published') . '=1')
->where($db->quoteName('id') . '=' . $db->quote($itemid));
$db->setQuery($query);
if ($link = $db->loadResult())
{
if ($router->getMode() == JROUTER_MODE_SEF)
{
$url = 'index.php?Itemid='.$itemid;
}
else {
$url = $link.'&Itemid='.$itemid;
}
}
}
if (!$url)
{
// Stay on the same page
$uri = clone JURI::getInstance();
$vars = $router->parse($uri);
unset($vars['lang']);
if ($router->getMode() == JROUTER_MODE_SEF)
{
if (isset($vars['Itemid']))
{
$itemid = $vars['Itemid'];
$menu = $app->getMenu();
$item = $menu->getItem($itemid);
unset($vars['Itemid']);
if (isset($item) && $vars == $item->query)
{
$url = 'index.php/?Itemid='.$itemid;
}
else {
$url = 'index.php?'.JURI::buildQuery($vars).'&Itemid='.$itemid;
}
}
else
{
$url = 'index.php?'.JURI::buildQuery($vars);
}
}
else
{
$url = 'index.php?'.JURI::buildQuery($vars);
}
}
return base64_encode($url);
}
public static function getType()
{
$user = JFactory::getUser();
return (!$user->get('guest')) ? 'logout' : 'login';
}
}