dou44364983
dou44364983
2013-01-30 14:04

登录后显示按钮

已采纳

i have a joomla login component,now i want when user successfully logs in to show a button that is hidden by css with display:none...here is how i tried...

<?php if (true === $app->login($credentials, $options)) {
        // Success

        $app->setUserState('users.login.form.data', array());
        $app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));
        ?><script>
        $$('.formBtn').setStyles({
  display:box;
});
        </script>
        <?php



    } else {
        // Login failed !
        $data['remember'] = (int)$options['remember'];
        $app->setUserState('users.login.form.data', $data);
        $app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
    }
}
?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • douxiaomang5640 douxiaomang5640 8年前

    this is how i did it eventually...

    <?php $user =& JFactory::getUser();
    if($user->id)
    {
    ?>
    
    
    <script>
    window.addEvent('domready', function() {
      $$('.formBtn').setStyle('display', 'block');
    });
    
    
    </script>
    <?php
    }
    else
    {
    echo "NOT LOGGED!";
    }
    
    ?>
    
    点赞 评论 复制链接分享
  • doumouyi4039 doumouyi4039 8年前

    You have several mistakes in your script:

    <script type="text/javascript">$(".formBtn").css("display", "box");</script>
    

    And remember to use this after the button is already rendered.

    点赞 评论 复制链接分享

相关推荐