欢迎。
我有一个奇怪的情况,因为我的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>
有人有这个问题吗?这可能是由于这种行为造成的。
[已解决]我的愚蠢错误。不要在注销链接中关闭标记,并且每次点击时身体都会做出反应。多么可惜..感谢您的关注。
答案 0 :(得分:0)
你的标签内有主框
在那里使用它作为最后3行,否则每次点击主框都会装备元素
<a href="/workflow/?r=user/logout"> </a>
<div class="main-box">
</div>
答案 1 :(得分:0)
您希望未登录用户使用的内容,请使用
if (Yii::app()->user->isGuest){
echo 'your content';
}
登录用户的内容
if (!Yii::app()->user->isGuest){
echo 'your content';
}
如果可行的话,现在让我。如果没有,您的UserIdentity类中有错误