Getting options from URL rewriting(从 URL 重写中获取选项)
问题描述
我继承了一个 Joomla 网站,我正在努力了解它是如何运作的.在 Joomla 2.5 中工作的遗留代码在 Joomla 3.7 中不再工作原始代码从 $_GET 中提取 URL 信息以构建要显示的页面的正确链接,如下所示:
I've inherited a Joomla site and I'm trying to learn how it all works. There's legacy code that works in Joomla 2.5 that no longer works in Joomla 3.7 The original code pulls the URL info from $_GET to build the correct link of the page to display, like this:
$search_str = array();
foreach ($_GET as $get_key => $get_value) {
array_push($search_str, $get_key . '=' . $get_value);
}
它在 2.5 中运行良好,但在 3.7 中没有返回任何内容.我正在尝试确定完成同一件事的新方法.我看过 JURI 和各种其他类/函数,但似乎找不到任何帮助.
It works fine in 2.5 but nothing is returned in 3.7. I am trying to determine the new method of accomplishing the same thing. I've lookat at JURI and a variety of other class/functions but can't seem to find anything to help.
推荐答案
访问 url 变量使用;
To access url variables use;
$app = JFactory::getApplication();
$var = $app->input->get(VARIABLE, DEFAULT);
不要期望 url 对 SEO 友好,为此您需要创建一个路由器 - https://docs.joomla.org/Supporting_SEF_URLs_in_your_component
Dont expect the url to be SEO friendly though, for that you need to create a router - https://docs.joomla.org/Supporting_SEF_URLs_in_your_component
编辑
戴尔.如果您 die(print_r(JFactory::getApplication()->input)); 并查看数据对象,您将看到它的属性是您期望的 url 部分,但它们受到保护所以你不能直接调用数据对象.相反,您需要像这样单独调用它们;
Hi Dale. If you die(print_r(JFactory::getApplication()->input)); and look at the data object you'll see its attributes are the url parts you are expecting, but they are protected so you cant just call the data object directly. Instead you need to use call them individually, like so;
$app = JFactory::getApplication();
$option = $app->input->get('option');
$view = $app->input->get('view');
$layout = $app->input->get('layout');
$id = $app->input->get('id');
$Itemid = $app->input->get('Itemid');
这篇关于从 URL 重写中获取选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 URL 重写中获取选项
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
