有没有方法来检查会话是否存在?
我试过这种方法,但它总是给我一个'勇敢!' 回答:
$session = $this->getRequest()->hasPreviousSession();
if($session)
{
return new Response('Bravo !');
}
else
{
return new Response('Oooops !');
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用javascript和刀片引擎编写一个简单的重定向,这是我想要做的一个例子:
javascript代码:
<p>Click the button to go to the home page</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r==true)
{
//Redirect to home
}
else
{
//stay here
}
document.getElementById("demo").innerHTML=x;
}
</script>
Run Code Online (Sandbox Code Playgroud)
当我使用return时Redirect::route('home')它不起作用,这样做的正确语法是什么,抱歉我的英语不好.
我有一个问题是使用Twig在循环中显示结果的下一行:
// Arkiglass/ProduitBundle/Controller/DefaultController.php
<?php
public function produitAction()
{
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery('SELECT p FROM ArkiglassProduitBundle:Produit p');
$produit = $query->getResult();
if (!$produit)
{
throw $this->createNotFoundException('no such Product !');
}
return $this->render('ArkiglassSiteBundle:Site:produit.html.twig', array(
'produit' => $produit
));;
}
Run Code Online (Sandbox Code Playgroud)
这是我的模板
{# produit.html.twig #}
{% for pr in produit %}
<table>
<tr>
<td>
{{ pr.description }}
</td>
<td>
{# display the next pr.description #}
</td>
</tr>
{% endfor %}
</table>
Run Code Online (Sandbox Code Playgroud)
我尝试使用{{ pr[loop.index+1].description }}但它对我不起作用.
我是Laravel 4的新手,我需要知道如何传递多个参数 URL::route
我的路线:
/*==========================
| edit-adherent (Get)
*///========================
Route::post('/manage-association/{id_association}/edit-adherent/{id_adherent}', array(
'as' => 'edit-adherent',
'uses' => 'AdherentController@postEditAdherent'
));
Run Code Online (Sandbox Code Playgroud)
我尝试了以下语法,但它不起作用:
<a href="{{ URL::route('edit-adherent', $id_association, $adherent->id) }}">Edit</a>
Run Code Online (Sandbox Code Playgroud)
我也试过那个:
<a href="{{ URL::route('edit-adherent', array($id_association, $adherent->id)}}">Edit</a>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,并抱歉我的英语不好