hendrikg
hendrikg

Reputation: 32

TYPO3 9 getting queryparameters in typoscript

In TYPO3 < 9 it was possible to set conditions in typoscript using query parameters like this:

// Set a condition when news extension plugin parameter "news" is set, e.g. url: // www.mysite.com?tx_news_pi1[news]=8

 [globalVar = GP:tx_news_pi1|news > 0]

...

[global]

with realurl you could rewrite the url to a pretty url and the above condition stil worked.

Now, in TYPO3 9 i don't use realurl anymore to rewrite the url, but the native rewriting module.

The condition does not work anymore.

As well using the new new symphony query language conditions does not work here:

[request.getQueryParams()['tx_news_pi1']['news'] > 0]
...
[global]

I debugged the request condition code, there are no query parameters. But in the news controller they arrive.

Question is: How can I set a condition like above to respond to extension query parameters in TYPO3 9 using the native url rewriting?

Upvotes: 0

Views: 1229

Answers (1)

chris
chris

Reputation: 2243

The old TYPOscript condition can be rewritten with this, but your example should work as well:

[traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
...
[END]

See changelog.

According to different configurations for news urls, you can set the limitToPages parameter in the sites YAML file, since there is no ext:realurl anymore:

Example:

routeEnhancers:
  NewsPluginOne:
    type: Extbase
    extension: News
    plugin: Pi1
    limitToPages: [20]
    routes:
      ...
  NewsPluginTwo:
    type: Extbase
    extension: News
    plugin: Pi1
    limitToPages: [21]
    routes:
      ...

With the above configuration you set different settings for the news url on the detail page with the id=20 and id=21.

Upvotes: 1

Related Questions