【问题标题】:Joomla PHP elseif redirecting page back to itselfJoomla PHP elseif将页面重定向回自身
【发布时间】:2013-02-28 17:24:00
【问题描述】:

由于某些 php 代码不断将其重定向到自身,我无法弄清楚如何让一个页面在不重定向到自身的情况下点击它的链接。

$option = $_GET[option];
$view = $_GET[view];

if (!$option) {
    include "include/index_main.php"; // INDEX MAIN TOP FILE
} 
elseif ($option == 'com_newsfeeds' and $view == 'newsfeed') {
    include "include/news.php"; // NEWS FILE
} 
elseif ($option == 'com_content' and $view == 'category') {
    switch($_GET[id]) {
        case '75':
            include "include/children_list.php"; // Children List FILE
            break;
        case '77':
            include "include/food_for_kids.php"; // Food 4 Kids page
            break;
        case '76':
            include "include/water_for_life.php"; // Water for Life page
            break;
        default:
            if (empty($_GET[listing_id]) || $_GET[listing_id] == '') {
                include "include/projects.php"; // Projects FILE
                break;  
            }
            else {
                include "include/project_list.php"; // Project Listing FILE 
                break;
            }
    }   
}
elseif... ... ...

当页面没有任何指向它自己的类别的链接时,这很有效,但是带有标记的地图都有链接,这些链接似乎被重定向回页面而不是它们应该去的地方。

问题出在 case '76': 部分

据我所知,当类别 id 为 76 时,php 调用 water_for_life.php 包含。不幸的是,它没有区分:

.org/index.php?option=com_content&view=category&id=76

.org/index.php?option=com_content&view=category&id=76&listing_id=76&sid=dl94q3tlfqr2s58c3u1mfnf1t1

毕竟,我想我的问题是:

有没有办法一直跳过到 include/project_list.php 一旦有人点击了具有如下链接的链接:

.org/index.php?option=com_content&view=category&id=76&listing_id=76&sid=dl94q3tlfqr2s58c3u1mfnf1t1

?

【问题讨论】:

    标签: php joomla


    【解决方案1】:

    你的意思是这样的?请注意,它适用于与 id 无关的所有情况,无论是 76 还是 77 或其他任何情况

    ...
    elseif ($option == 'com_content' and $view == 'category') {
    if (!empty($_GET['listing_id'])) {
        include "include/project_list.php"; // Project Listing FILE 
    }
    else {
      switch($_GET['id']) {
        case '75':
            include "include/children_list.php"; // Children List FILE
            break;
        case '77':
            include "include/food_for_kids.php"; // Food 4 Kids page
            break;
        case '76':
            include "include/water_for_life.php"; // Water for Life page
            break;
        default:
            include "include/projects.php"; // Projects FILE
            break;  
        } 
    }
    ...
    

    【讨论】:

    • 你先生,太棒了@Marko。谢谢!我在这方面完全是新手,但要了解和了解更多。我希望我可以投票,一旦我获得足够的代表,我会投票的。
    猜你喜欢
    • 2011-07-25
    • 2013-10-14
    • 2021-05-19
    • 2017-05-08
    • 1970-01-01
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 2015-08-07
    相关资源
    最近更新 更多