Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 在uri生成器中保留参数_Typo3_Extbase_Typo3 6.1.x_Realurl_Uribuilder - Fatal编程技术网

Typo3 在uri生成器中保留参数

Typo3 在uri生成器中保留参数,typo3,extbase,typo3-6.1.x,realurl,uribuilder,Typo3,Extbase,Typo3 6.1.x,Realurl,Uribuilder,假设我有一个URI为的页面: http://mydomain.loc/index.php?id=123&by=name&dir=desc 并且需要向其添加/更新/删除一些其他参数(让我们将其命名为offset),因此它毕竟是: http://mydomain.loc/index.php?id=123&by=name&dir=desc&offset=321 不幸的是,当像这样使用uriBuilder构建新链接时 $uriBuilder = $this

假设我有一个URI为的页面:

 http://mydomain.loc/index.php?id=123&by=name&dir=desc
并且需要向其添加/更新/删除一些其他参数(让我们将其命名为offset),因此它毕竟是:

 http://mydomain.loc/index.php?id=123&by=name&dir=desc&offset=321
不幸的是,当像这样使用
uriBuilder
构建新链接时

$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder->setArguments(array('offset' => 321))->build();
我只得到
index.php?id=123&offset=321
(不再使用
by
dir
参数…)

如何强制uriBuilder保留这些参数?(通过
GeneralUtility::\u GP(*)
手动重写参数是不可能的,因为它们在理论上是未知的)


另外,
$\u GET
数组并不好,因为我正在使用RealURL编写uriBuilder有一个
setAddQueryString
方法,它完全满足您的需要。它将当前查询字符串合并到参数中:

$uri = $this->uriBuilder->setArguments(array('offset' => 321))->setAddQueryString(TRUE)->build();
作为参考,这里是从TYPO3 core的实际类复制的方法:

/**
 * If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
 *
 * @param boolean $addQueryString
 * @return \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder the current UriBuilder to allow method chaining
 * @api
 * @see TSref/typolink.addQueryString
 */
public function setAddQueryString($addQueryString) {
    $this->addQueryString = (boolean) $addQueryString;
    return $this;
}