doulai5585 2013-03-19 02:12
浏览 48
已采纳

根据用户组重定向到登录页面或主页索引

I tried Googling and using forums.joomla.org, because I wanted to make sure I wasn't wasting people's time on here, but unfortunately I have had no luck. Here's my issue:

For my website, I have both a landing page which only has the link to register for free to become a member, and a proper index page which users access after they become registered. I set up the landing page as kanadax.ca/ because I want people to land there when they first come to the page. My real index page is located at kanadax.ca/index.php. However, now when users are already logged in and they click on the website logo to go to the root domain, they get a page not found error.

So what I want to do is: - If it's a non-registered guest user, have the logo redirect to the landing page located at kanadax.ca/. - Once a user becomes registered, anytime they go to kanadax.ca/index.php it should redirect to example.com/index.php.

Basically I'm looking for conditional redirecting based on user groups. Any ideas?

Now obviously I would actually prefer example.com/ url as main index page rather than the less attractive example.com/index.php but that's a second step after I fix the redirection. I believe it can be done with .htaccess but with the more complicated landing page - index page structure that I have for guest and registered users I think it may be a bit difficult. However, please do give feedback if you have any in this area as well.

I should mention I'm not super comfortable with php but I'm happy to try any suggestions if you'd like to give me a step by step. After all, my first goal in making this website is to learn!

Thanks a heap!

PS if necessary, I'm happy to provide a test account so you can play around with the website yourselves.

**Edit:

Hey @Adam, I really appreciate the input and the step by step, it's exactly what I needed. Now, I have put the first section at the beginning of index.php, however for the latter part, I'm not quite sure where to put it. When I search for anything logo related within index.php, two separate sections come up:

// Logo file or site title param
if ($this->params->get('logoFile'))
{
  $logo = '<img src="'. JURI::root() . $this->params->get('logoFile') .'" alt="'. $sitename .'" />';
}
elseif ($this->params->get('sitetitle'))
{
  $logo = '<span class="site-title" title="'. $sitename .'">'. htmlspecialchars($this->params->get('sitetitle')) .'</span>';
}
else
{
  $logo = '<span class="site-title" title="'. $sitename .'">'. $sitename .'</span>';
}

and

<div class="header">
        <div class="header-inner clearfix">
          <a class="brand pull-left" href="http://www.kanadax.ca/index.php/anasayfa">
            <?php echo $logo;?> <?php if ($this->params->get('sitedescription')) { echo '<div class="site-description">'. htmlspecialchars($this->params->get('sitedescription')) .'</div>'; } ?>
          </a>
          <div class="header-search pull-right">
            <jdoc:include type="modules" name="position-0" style="none" />
          </div>
        </div>
      </div>

second part being under header. Do you think either of these is the right section? If so, should I delete what is in there and replace with your suggestion, or keep it?

  • 写回答

2条回答 默认 最新

  • douseda0009 2013-03-19 08:23
    关注

    Try to modify your template index.php file in the following way:

    1. Add this somewhere at the begin of the code

      $user = JFactory::getUser();
      if(JFactory::getUser()->id)
      {
          //link to page for registered users 
          $link =  JRoute::_('index.php?option=com_content&view=article&id=3');
      }else{
          //link to page for default users 
          $link =  JRoute::_('index.php?option=com_content&view=article&id=1');   
      }
      
    2. In the place where the logo should be displayed

      <a href="<?php echo $link; ?>">
          <img src="images/path_to_image_name"/>
      </a>
      

    And that is it! Latter when you are more familiar with Joomla and PHP you may create a custom module instead of injecting the template directly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP