<i id='8NlBr'><tr id='8NlBr'><dt id='8NlBr'><q id='8NlBr'><span id='8NlBr'><b id='8NlBr'><form id='8NlBr'><ins id='8NlBr'></ins><ul id='8NlBr'></ul><sub id='8NlBr'></sub></form><legend id='8NlBr'></legend><bdo id='8NlBr'><pre id='8NlBr'><center id='8NlBr'></center></pre></bdo></b><th id='8NlBr'></th></span></q></dt></tr></i><div id='8NlBr'><tfoot id='8NlBr'></tfoot><dl id='8NlBr'><fieldset id='8NlBr'></fieldset></dl></div>

    <bdo id='8NlBr'></bdo><ul id='8NlBr'></ul>

  1. <legend id='8NlBr'><style id='8NlBr'><dir id='8NlBr'><q id='8NlBr'></q></dir></style></legend>
    <tfoot id='8NlBr'></tfoot>
  2. <small id='8NlBr'></small><noframes id='8NlBr'>

      如何仅在 joomla 主页上显示消息?

      时间:2023-10-16
            <bdo id='G76hW'></bdo><ul id='G76hW'></ul>
            1. <legend id='G76hW'><style id='G76hW'><dir id='G76hW'><q id='G76hW'></q></dir></style></legend>

              <small id='G76hW'></small><noframes id='G76hW'>

                <i id='G76hW'><tr id='G76hW'><dt id='G76hW'><q id='G76hW'><span id='G76hW'><b id='G76hW'><form id='G76hW'><ins id='G76hW'></ins><ul id='G76hW'></ul><sub id='G76hW'></sub></form><legend id='G76hW'></legend><bdo id='G76hW'><pre id='G76hW'><center id='G76hW'></center></pre></bdo></b><th id='G76hW'></th></span></q></dt></tr></i><div id='G76hW'><tfoot id='G76hW'></tfoot><dl id='G76hW'><fieldset id='G76hW'></fieldset></dl></div>

                <tfoot id='G76hW'></tfoot>
                  <tbody id='G76hW'></tbody>
              • 本文介绍了如何仅在 joomla 主页上显示消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何只在joomla的首页显示一条消息?我有兴趣在 site.com 上显示它,而不是在 site.com/index.php/page 或其他任何网站上显示它.

                How can I display a message only on the homepage of joomla? I am interested in displaying it on site.com and not site.com/index.php/page or anything else then site.com.

                我已经测试了以下内容:

                I have tested the following:

                    <?php $app = JFactory::getApplication(); 
                    $menu = $app->getMenu(); 
                    $lang = JFactory::getLanguage(); 
                if ($menu->getActive() == $menu->getDefault($lang->getTag())) : ?>this is the homepage
                    <?php endif; ?>
                

                还有这个

                <?php $menu = & JSite::getMenu();
                if ($menu->getActive() == $menu->getDefault()) {
                    echo "this is the homepage";
                }
                ?>
                

                问题是我仍然可以在诸如http://site.com/index.php/category/id/78-article 这显然不是主页.好像只要链接里有index.php,上面的代码就认为是首页的.

                The problem is that I can still see the message "this is the homepage" on pages like http://site.com/index.php/category/id/78-article which clearly isn't the homepage. It seems that whenever there is index.php in the link, the above code thinks it belongs to the homepage.

                推荐答案

                这与链接中的index.php"无关.相反,它与 http://site.com/上的链接有关index.php/category/id/78-article 没有与之关联的菜单项.要完全按照您的要求执行操作,您可能需要对代码进行一些处理,并检查以确保实际页面的信息与主页信息匹配:

                This has nothing to do with the 'index.php' in the link. Instead it is related to the fact that the link at http://site.com/index.php/category/id/78-article does not have a menu item associated with it. To do exactly what you are wanting, you will probably need to get a little trickier with the code and check to make sure that the actual page's information matches the homepage information:

                $jinput = JFactory::getApplication()->input;
                $menu = & JSite::getMenu();
                $active = $menu->getActive();
                $default = $menu->getDefault();
                if (
                    $active == $default && 
                    $jinput->get('option') == $default->query['option'] && 
                    $jinput->get('view') == $default->query['view'] && 
                    $jinput->get('id') == $default->query['id']
                ) {
                    echo "This is the homepage";
                }
                

                我正在检查默认菜单项选项(哪个组件)以及针对输入中设置的视图和 id 值.

                I am checking the default menu items option (which component) and view and id values against those set in the input.

                http://site.com/index.php/category/id/78-article 此链接会将 id 设置为 78,并且可能会更改主页菜单中定义的视图和选项,因此不会发生触发器.

                http://site.com/index.php/category/id/78-article This link will set the id to 78 and likely change the view and option from what it is defined as in the menu for the homepage, so the trigger will not occur.

                这篇关于如何仅在 joomla 主页上显示消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Debian 9 + PHP7.0-FPM + NGINX 1.10.3-1 path_info 问题 下一篇:为 Wordpress、Joomla 或 Drupal 等 CMS 制作可安装模板是否需要具备良好的 PHP 知识?

                相关文章

              • <legend id='haQlG'><style id='haQlG'><dir id='haQlG'><q id='haQlG'></q></dir></style></legend>
                  <bdo id='haQlG'></bdo><ul id='haQlG'></ul>

              • <i id='haQlG'><tr id='haQlG'><dt id='haQlG'><q id='haQlG'><span id='haQlG'><b id='haQlG'><form id='haQlG'><ins id='haQlG'></ins><ul id='haQlG'></ul><sub id='haQlG'></sub></form><legend id='haQlG'></legend><bdo id='haQlG'><pre id='haQlG'><center id='haQlG'></center></pre></bdo></b><th id='haQlG'></th></span></q></dt></tr></i><div id='haQlG'><tfoot id='haQlG'></tfoot><dl id='haQlG'><fieldset id='haQlG'></fieldset></dl></div>

                <small id='haQlG'></small><noframes id='haQlG'>

                  <tfoot id='haQlG'></tfoot>