0

欢迎。

我有一个奇怪的情况,因为我的 Yii 框架本身会生成注销链接并将其放在每个元素(span、div、li 和其他)的视图主体中通过这个问题,每次单击视图主体时我都会得到已登出

为了生成视图,我使用了 $this->render();

结果 DOM 看起来像这样:

<section class="top-line">
    <div class="right">
         <a href="/workflow/?r=user/logout"> </a>
    </div>
    <a href="/workflow/?r=user/logout"> </a>
</section>
<a href="/workflow/?r=user/logout">
  <div class="main-box">...</div>
</a>

<footer>
<a href="/workflow/?r=user/logout"> </a>
<div class="container">..</div>
</footer>

@DarkMukke 包括布局/main.php:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />
    <link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/favicon.ico" type="image/x-icon" />
    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/print.css" media="print" />
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/ie.css" media="screen, projection" />
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/form.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/blue/style.css" />

    <?php
    $cs = cs();
    $cssCoreUrl = $cs->getCoreScriptUrl();
    $cs->registerCssFile($cssCoreUrl . '/jui1.9.2/css/base/jquery-ui.css');
    $cs->registerCoreScript('jquery');
    $cs->registerCoreScript('jquery.ui');
    $cs->registerCoreScript('cookie');
    $cs->registerScriptFile('js/block.js');
    $cs->registerScriptFile('js/global.js');
    $cs->registerScriptFile('css/blue/style.js');
    ?>

    <title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body>

    <header class="top">
        <div class="container">
            <div class="logo">
                <h1><a href="<?php echo Yii::app()->baseUrl; ?>" ><?php echo CHtml::encode(Yii::app()->name); ?></a></h1>
            </div>
            <nav>
                <?php $this->widget('Menu'); ?>
            </nav>
        </div>
    </header>

    <section class="top-line">
        <div class="container">
            <?php if (isset($this->breadcrumbs)): ?>
                <div class="left">
                    <?php
                    $this->widget('zii.widgets.CBreadcrumbs', array(
                        'links' => $this->breadcrumbs,
                    ));
                    ?>
                </div>
            <?php endif ?>
            <?php if (Yii::app()->user->isGuest == false): ?>
                <div class="right">
                    <a href="<?php echo url('/user/logout'); ?>"><?php echo t('Logout') . ' (' . Yii::app()->user->name . ')'; ?>
                </div>
            <?php endif; ?>
        </div>
    </section>

    <div class="main-box">
         <div class="container clear">
                <div class="clear cenetr">
                    <?php
                    foreach (Yii::app()->user->getFlashes() as $key => $message) {
                        echo '<div class="flash-' . $key . '">' . $message . " <span class=\"close-flush-btn\"></span></div>\n";
                    }
                    ?>
                </div>
        </div>
        <div class="wrapper">
            <?php echo $content; ?>
        </div>
    </div>
    <footer>
        <div class="container">
            <div class="wrapper">
                <div class="fleft"><?php echo Yii::app()->params['copyrightInfo']; ?></div>
                <div class="fright"><?php echo Yii::powered(); ?></div>
            </div>
        </div>
    </footer>
</body>

有人遇到过这个问题吗?这可能是由这种行为造成的。

[已解决] 我的愚蠢错误。不要在注销链接中关闭标签,并且正文会在每次点击时做出反应。真可惜..感谢您的关注。

4

2 回答 2

0

您的标签内有主框

将其用作那里的最后 3 行,否则每次单击主框都不会触发元素

<a href="/workflow/?r=user/logout"> </a>
<div class="main-box">
</div>
于 2013-01-11T10:35:11.297 回答
0

您希望未登录的用户可以使用的内容,请使用

if (Yii::app()->user->isGuest){
echo 'your content';
}

登录用户的内容

if (!Yii::app()->user->isGuest){
echo 'your content';
}

Let me now if that works. If it doesn't, you have something wrong in your UserIdentity class

于 2013-01-11T13:28:25.117 回答