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

      <legend id='XfUh0'><style id='XfUh0'><dir id='XfUh0'><q id='XfUh0'></q></dir></style></legend>

      1. <tfoot id='XfUh0'></tfoot>
        • <bdo id='XfUh0'></bdo><ul id='XfUh0'></ul>
      2. <small id='XfUh0'></small><noframes id='XfUh0'>

        从 Joomla 模块发出重定向

        Issuing a redirect from a Joomla module(从 Joomla 模块发出重定向)

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

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

                  <tbody id='X7859'></tbody>

                  <bdo id='X7859'></bdo><ul id='X7859'></ul>
                • 本文介绍了从 Joomla 模块发出重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对 Joomla 不是很熟悉,但我的任务是编写一个模块,该模块的功能与问题无关.

                  I am not really familiar with Joomla but I have been tasked with writing a module which functionality is irrelevant to the question.

                  其中一个要求是,如果模块被加载,它应该检查用户是否登录,如果没有 - 将他重定向到特定的 URL.

                  One of the requirements is that if the module is loaded, it should check if the user is logged in and if not - redirect him into a specific URL.

                  经过一番搜索,我想出了类似的东西,但这显然不是一个有效的答案:

                  After some searching I came up with something like this, but it's obviously not a working answer:

                  $user =& JFactory::getUser();
                  
                  if (!$user->id) {
                      include_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . "controller.php"; // assuming com_content
                      $contentController = new ContentController();
                      $link = JRoute::_("my url");
                      $contentController->setRedirect($link);
                      return;
                  }
                  

                  我认为问题在于获取控制器.创建一个新的控制器当然不是要走的路.有没有办法从 Joomla 模块获取当前控制器并发出重定向?

                  I think the problem lies in getting to the controller. Creating a new controller certainly isn't the way to go. Is there a way to get the current controller from a Joomla module and the issue a redirect?

                  感谢您的回答.

                  推荐答案

                  我在我的每个控制器构造中调用这个静态函数

                  i call this static function in each of my controllers construct

                  static function forceLoggedIn(){
                  
                  
                      $user = JFactory::getUser();
                  
                          if($user->guest||$user->id == 0)
                          {
                              $error = JText::_('YOU MUST BE LOGGED IN');
                              //base xkè altrimenti andrebbe in loop di redirect
                              JFactory::getApplication()->redirect(JURI::base(), $error, 'error' );
                              return false;
                          }
                      }
                  

                  这篇关于从 Joomla 模块发出重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='3bylW'></small><noframes id='3bylW'>

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