English 中文(简体)
2. 与Same页链接
原标题:Creating Link to Same Page with Request Parameters in Symfony

如何利用旋转接或把_与助手连接起来,与沿所有GET参数的同一页建立联系?

我有一个搜索页,接受多个参数作为过滤器,以掩盖某些结果。 例如,search.html?query=abc&people=1&groups=0将搜寻所有含有原体的垃圾箱的物品。 因此,我要把这些过滤器汇集起来,把参数的其余部分改到目前的网页。 在上述例子中,将建立以下链接:<代码>search.html?query=abc&people=1&groups=1和search.html?query=abc&people=0&groups=0

I am wondering if there is any way to specify this as a route, such that if the route or page changed, the code wouldn t have to.

此外,如何把所有参数传递给帮助者? 可以用来获取所有参数,而询问——描述财产可以传给帮助者,但是否有任何办法将这两种缺陷与人工制造混凝土结合起来?

最佳回答

GET参数可转至link_to。 作为第三点的一个阵列,或url_for在第二处。 说明如下:

link_to( Text to display ,  routename , array( group  => 0,  people  => 1), $link_attributes);
url_for( routename , array( group  => 0,  people  => 1));

这在来源法中是隐蔽的。 此处$为全球升温潜能值参数清单,$options 添加标记的超文本属性。

function link_to2($name, $routeName, $params, $options = array())
function url_for2($routeName, $params = array(), $absolute = false)

<代码>sf_params功能可转换成一个合适的阵容,通过getAll(。 见here。 请注意,这与以往版本的国名不同。 还意识到您可能不得不在模板内打电话getRawValue():

$params = $sf_params->getRawValue()->getAll();

$sf_context->getInstance()->getRouting()->getCurrentRouteName() can then be passed as $routeName to get the current route. Thanks to Tom for this

问题回答

put vars in hidden form data types to pass them on

<form action="page.php" method="GET">
<input name="people" type="hidden" value="<?php echo htmlspecialchars($_GET[ people ], ENT_QUOTES); ?>">
<input name="groups" type="hidden" value="<?php echo htmlspecialchars($_GET[ groups ], ENT_QUOTES); ?>">
<input name="query" type="text" value="some_data">
<input name="send" type="submit" value="send">
</form>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签