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条)

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计