添加子 php 页面时更改 Joomla 中的 URI 后缀

发布于 2024-08-29 06:54:02 字数 1665 浏览 2 评论 0原文

我在我的 joomla 网站中添加了一个新目录:

http://sitedomain.tld/xxx/

然后我在该目录中添加了index.php,

这里是代码

    define( '_JEXEC', 1 );

define('JPATH_BASE', '..' );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( '../includes/defines.php' );
require_once ( '../includes/framework.php' );




//JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */



$mainframe =& JFactory::getApplication('site');
$template_name = $mainframe->getTemplate();;

$mainframe->initialise();

JPluginHelper::importPlugin('system');


/**
 * ROUTE THE APPLICATION
 *
 * NOTE :
 */
$mainframe->route();

// authorization
$Itemid = JRequest::getInt( 'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
//JDEBUG ? $_PROFILER->mark('afterRoute') : null;
//$mainframe->triggerEvent('onAfterRoute');

/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option = JRequest::getCmd('option');
//$mainframe->dispatch($option);

// trigger the onAfterDispatch events
//JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
//$mainframe->triggerEvent('onAfterDispatch');

/**
 * RENDER  THE APPLICATION
 *
 * NOTE :
 */

$mainframe->render();    


/**
 * RETURN THE RESPONSE
 */

var_dump($document->getHeadData());
echo JResponse::toString($mainframe->getCfg('gzip'));

sdwdwd wdwd

当我在浏览器中查看此页面时,所有动态链接(如 CSS、JS 和图像)都带有 /xxx/ 路径后缀,这使得它们损坏!

如何删除此后缀或如何将此后缀从 /xxx 更改为 / 以使其指向原始文件位置?

我尝试设置 JDocument::setBase 并尝试使用 JURI 对象并更改其 _path 和 _uri 而不进行任何更改

谢谢

I have added a new directory in my joomla website:

http://sitedomain.tld/xxx/

then I have added index.php in that directory

here is the code

    define( '_JEXEC', 1 );

define('JPATH_BASE', '..' );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( '../includes/defines.php' );
require_once ( '../includes/framework.php' );




//JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */



$mainframe =& JFactory::getApplication('site');
$template_name = $mainframe->getTemplate();;

$mainframe->initialise();

JPluginHelper::importPlugin('system');


/**
 * ROUTE THE APPLICATION
 *
 * NOTE :
 */
$mainframe->route();

// authorization
$Itemid = JRequest::getInt( 'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
//JDEBUG ? $_PROFILER->mark('afterRoute') : null;
//$mainframe->triggerEvent('onAfterRoute');

/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option = JRequest::getCmd('option');
//$mainframe->dispatch($option);

// trigger the onAfterDispatch events
//JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
//$mainframe->triggerEvent('onAfterDispatch');

/**
 * RENDER  THE APPLICATION
 *
 * NOTE :
 */

$mainframe->render();    


/**
 * RETURN THE RESPONSE
 */

var_dump($document->getHeadData());
echo JResponse::toString($mainframe->getCfg('gzip'));

sdwdwd
wdwd

When I view this page in the browser, all the dynamic links like CSS, JS and images were suffixed by the /xxx/ path which make them broken !

How can I drop this suffix or how do I change this suffix from /xxx to / to it points to the original files location?

I have tried setting the JDocument::setBase and also tried to play with the JURI object and changed its _path and _uri without any change

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

像你 2024-09-05 06:54:02

JPATH_BASE 不应该是绝对路径(例如 realpath('..'))吗?

另外,您可以尝试在模板中进行设置。

Shouldn't JPATH_BASE be an absolute path (eg. realpath('..'))?

Also, you can try setting in template.

自控 2024-09-05 06:54:02

我不建议像这样绕过 Joomla 渲染过程。创建一个组件比尝试执行您的目标会更好。

本质上,我认为问题在于您实际上正在创建一个新实例,并且太多的事情期望资源位于某些路径中。你在这里自找麻烦,我什至无法想象所有会受到此移动影响的设置。这就是为什么我不会这样做,也不会制作一个组件。

I don't recommend circumventing the Joomla rendering process like this. You would be much better off creating a component rather than trying to do whatever you're goals are here.

Essentially I think the issue is you're actually creating a new instance and too many things expect resources to be located in certain paths. You're asking for a lot of trouble here, I can't even being to think of all the settings that would be affected by this move. That is why I would not do this, and make a component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文