可能重复:
页面历史记录 - 后退按钮是否存在?
我需要在网站的某些页面中有一个链接,通过点击它,它需要返回上一页,就像浏览器的后退按钮一样.这样做的正确方法是什么?我想我应该像Javascript一样使用一些客户端脚本,对吧?
当我试图删除帖子时,我收到此错误:
Yii Error 400 The CSRF token could not be verified
Run Code Online (Sandbox Code Playgroud)
我不知道究竟是什么造成了这种情况以及它可能与之相关.这是我的动作删除:
public function actionDelete($id) {
if (Yii::app()->request->isPostRequest) {
// we only allow deletion via POST request
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if (!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
else
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
protected function afterDelete()
{
parent::afterDelete();
Image::model()->deleteAll('name='.$this->id);
Date::model()->deleteAll('tbl_show_id='.$this->id);
Press::model()->deleteAll('tbl_show_id='.$this->id);
}
Run Code Online (Sandbox Code Playgroud) 我想从仍然出现在Google搜索中的旧网址重定向到新网址.旧网址是这样的:
http://www.marionettecolla.org/file%20_mostra_milano/mostra_marionette-milano.htm
Run Code Online (Sandbox Code Playgroud)
我想将其重定向到主页:
http://www.marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)
我在我的.htaccess中使用了这个:
Redirect http://marionettecolla.org/file\ _mostra_milano/mostra_marionette-milano.htm http://marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)
但我得到错误500 ...有谁知道如何解决这个问题?
我在C#中使用HashSetand Dictionary来实现Graph结构.HashSet当HashSet键是自定义类时,我遇到元素唯一性的问题.我在这里:
public class Point
{
public int x { get; set; }
public int y { get; set; }
}
public class Vertex
{
public Vertex(Point point)
{
VertexLabel = point;
}
public Point VertexLabel { get; private set; }
}
public class Edge
{
public Edge(Vertex to, Vertex from, double weight)
{
FromVertex = from;
ToVertex = to;
Weight = weight;
}
public Vertex FromVertex { get; private set; }
public …Run Code Online (Sandbox Code Playgroud) 我正在使用Yii作为应用程序,我正在编写一个非常简单的用户管理,如注册,删除和更新用户......为了更新现有用户,我需要先检查旧密码,然后再将其更改为新插入的密码.所以这里是我在表单中的字段:
username:----
old_password:---
new_password:---
Run Code Online (Sandbox Code Playgroud)
我的用户表看起来像这样:
id, username, password
Run Code Online (Sandbox Code Playgroud)
如何在使用new_password更新之前验证old_password?我知道通常的PHP编码,但我想知道是否有任何Yii技巧自动执行此操作...
提前致谢
我正在开发Yii应用程序.我试图在我的主配置参数中设置一些路径,如下所示:
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
'paths' => array(
'imageTemp'=> Yii::getPathOfAlias('webroot').'/files/temp-',
'image'=> Yii::getPathOfAlias('webroot').'/files/',
...
),
'urls' => array(
'imageTemp'=> Yii::app()->getBaseUrl().'/files/temp-',
'image'=> Yii::app()->getBaseUrl().'/files/',
...
),
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
Fatal error: Call to a member function getBaseUrl() on a non-object in ..blahblah../base/CApplication.php on line 553
Run Code Online (Sandbox Code Playgroud)
我想我不能在配置文件中使用Yii :: app(),因为应用程序尚未在此处初始化,或类似的东西.那么,如何Yii::app()->getBaseUrl()在配置文件中替换并获得相同的结果?
我想为我的yii应用程序使用一个主题.列出投资组合部分的项目我正在使用CListView.在模板中它使用列表(<ul>和<li>标签)来显示组合元素,因为我不想浏览所有文件和jquery的东西,我想做同样的事情.但是CListView默认添加了一些div标签.我需要知道CListView是否有任何配置使用<ul>标签而不是<div>为它设置类?
这就是我所拥有的:
<ul class="clearfix port-det port-thumb">
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
));
?>
</ul>
Run Code Online (Sandbox Code Playgroud)
并在_view.php中:
<li data-id="web print" class="clearfix">
...
</li>
Run Code Online (Sandbox Code Playgroud)
我最终得到的HTML代码是这样的:
<ul class="clearfix port-det port-thumb">
<div id="yw0" class="list-view">
<div class="summary">Displaying 1-8 of 9 result(s).</div>
<div class="items">
<li class="clearfix" data-id="web print">
...
</li>
</div>
<div>
</ul>
Run Code Online (Sandbox Code Playgroud)
更新:我需要这样的东西:
<ul class="clearfix port-det port-thumb">
<li class="clearfix" data-id="web print">
...
</li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我将类别和子类别保存在数据库中.我想在这样的CHtml下拉列表中显示它们:
Patrent_cat
sub_cat1
sub_cat2
Parent_cat2
...
Run Code Online (Sandbox Code Playgroud)
我的类别表是这样的
id name parent_id
Run Code Online (Sandbox Code Playgroud)
如果元组是父本身,则parent_id为0
我已经在我的分类模型中尝试了这个:
public function relations()
{
return array(
'getparent' => array(self::BELONGS_TO, 'Category', 'parent_id'),
'childs' => array(self::HAS_MANY, 'Category', 'parent_id', 'order' => 'id ASC'),
);
}
public function getCategoryTree()
{
$subitems = array();
if($this->childs) foreach($this->childs as $child)
{
$subitems[] = $child->getListed();
}
$returnarray = array($this->id => $this->title);
if($subitems != array())
$returnarray = array_merge($returnarray, array('items' => $subitems));
return $returnarray;
}
Run Code Online (Sandbox Code Playgroud)
在我看来:
<?php
echo CHtml::dropDownList('category', 'id',
Category::model()->CategoryTree,
array('empty' => '(Select a category'));
?>
Run Code Online (Sandbox Code Playgroud)
但它给了我一个空的下拉列表.如何在带有选项组的下拉列表中显示此树视图?(选项组是父类别,选项是sub_categories.
我尝试研究类似的问题,但没有一个解决方案可以帮助我的问题。
我在 Ubuntu 16.04 LTS 上的 Virtualbox 上使用 Hortonworks HDP 2.6.5 沙箱。Hortonworks 正在运行,VirtualBox 上显示以下内容:
按照说明,我使用 localhost 上的 4200 端口进行 ssh,命令如下:
ssh [user]@127.0.0.1 -p 4200
Run Code Online (Sandbox Code Playgroud)
这导致我出现以下错误:
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)
我尝试调试,得到以下日志:
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 4200.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_rsa type -1
debug1: key_load_public: No such file …Run Code Online (Sandbox Code Playgroud) 我对MVC和Yii框架很新,因此很有可能我的问题非常愚蠢.如果是这样,请提前接受我的预测.
我希望在我的网站管理部分中有一个表单,用户可以在其中发布一些内容.我按照示例博客的教程,但似乎添加到数据库中定义为文本的字段(我的表单中的textarea)的内容在提交表单后没有得到更新(其他一切正常).这是我的表的sql语句:
CREATE TABLE `tbl_show` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`presentation` text,
PRIMARY KEY (`id`),
KEY `fk_tbl_show_tbl_season1` (`tbl_season_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
Run Code Online (Sandbox Code Playgroud)
我使用Gii制作我的模型和CRUD,我只在这里添加可能相关的部分:
在我的控制器上:
public function actionCreate()
{
$model=new Show;
if(isset($_POST['Show']))
{
$model->attributes=$_POST['Show'];
if($model->save())
{
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
Run Code Online (Sandbox Code Playgroud)
和我的_form.php:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'show-form',
'enableAjaxValidation'=>false,
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'presentation'); ?>
<?php echo $form->textArea($model,'presentation',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'presentation'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord …Run Code Online (Sandbox Code Playgroud) 如何在另一个模块中调用模块?此代码适用于受保护/控制器中的控制器:
$image = Yii::app()->image->save($photofile, 'some_name','uploadedGal');
Run Code Online (Sandbox Code Playgroud)
但在我的其他模块(admin)的控制器中,我得到了这个错误.
Property "CWebApplication.image" is not defined.
Run Code Online (Sandbox Code Playgroud)
我image在主配置文件中定义了模块:
'modules'=>array(
'image'=>array(
'createOnDemand'=>true, // requires apache mod_rewrite enabled
'install'=>true, // allows you to run the installer
),
'admin',
),
Run Code Online (Sandbox Code Playgroud) 由于我是 XAML 和 WPF 的新手,我的问题可能不明确。提前接受我的道歉。
为了简单起见,我正在开发一个项目,其中有一些按钮和一个自定义指针来选择这些按钮之一。我可以让程序正常运行,而无需使用网格行和列来组织我的元素。然而,当我最大化窗口时,情况变得一团糟。因此,我使用具有百分比宽度和高度的网格行和列来解决这个问题。但现在,指针卡在其中一个网格中,无法移出。我想以某种方式定义我的指针,使其可以沿着整个网格移动,而无需绑定到行或列。这是我的 XAML 代码:
<Window x:Class="testGallery.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local ="clr-namespace:Kinect.Toolbox;assembly=Kinect.Toolbox"
Loaded="Window_Loaded"
Title="MainWindow">
<Grid Margin="0,0,0,97">
<Grid.RowDefinitions>
<RowDefinition Height="68*" />
<RowDefinition Height="101*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150*" />
<ColumnDefinition Width="150*" />
</Grid.ColumnDefinitions>
<Button Click="Button_Click_1" Grid.Column="1" Grid.Row="1" Margin="10" >
<StackPanel>
<Image x:Name="myImage" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5"/>
</StackPanel>
</Button>
<Canvas x:Name="mouseCanvas" Margin="-24,263,24,-263"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,Convas 是我的自定义指针。