【问题标题】:Remove Prefix from URL in Joomla Menu从 Joomla 菜单中的 URL 中删除前缀
【发布时间】:2012-08-21 09:56:27
【问题描述】:

我有一个使用 Joomla 2.5 构建的站点,并且该站点必须与其他框架中构建的另一个应用程序集成(这与我们无关)。

Joomla 站点/前端可通过以下 URL http://wwww.server.com/

访问

应用程序保存在 http://www.server.com/app/

我正在尝试使用以下代码 sn-p 将 Joomla Admin 中定义的菜单重新创建到应用程序侧边栏中

define( '_JEXEC', 1 );
define('JPATH_BASE', realpath(dirname(__FILE__)."/../"));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModules('left');
echo JModuleHelper::renderModule($module[0]);

这会在非 Joomla 页面上完美生成菜单,但是为 HREF 属性生成的 URL 包含其中包含的 /app/,它不应该存在

【问题讨论】:

    标签: php joomla


    【解决方案1】:

    在对路由、uri 等文件进行了大量研究之后,我在上面提到的代码中添加了一个脏修复/hack 以生成正确的菜单 URL:

    define( '_JEXEC', 1 );
    define('JPATH_BASE', realpath(dirname(__FILE__)."/../"));
    define( 'DS', DIRECTORY_SEPARATOR );
    require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
    require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
    
    $mainframe =& JFactory::getApplication('site');
    $JConfig=JFactory::getConfig();
    $JConfig->set('live_site','http://www.server.com/');
    jimport( 'joomla.application.module.helper' );
    $module = JModuleHelper::getModules('left');
    echo JModuleHelper::renderModule($module[0]);
    

    我在这里尝试将“live_site”配置设置为网站的基本网址。

    我希望这对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-29
      • 2013-01-11
      • 2015-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 2020-03-31
      相关资源
      最近更新 更多