Title: How to add additional argument to all templates in play framework
Tags: routing;playframework
Question: We have completed 95% of our application. We want to add additional argument mode=1 to all templates URLS's in the browser. Is it possible by adding in one place like routing file,

The URL should be like be visible in the address bar. 

Suppose, the original url is 

```http://localhost:9000/design/customersList
```

it needs to be add the mode=1, which will be like  

```http://localhost:9000/design/customersList?mode=1
```

Generally

```http://localhost:9000/{module}/{action}?mode=1
```

Comment: I have to pass in all the URL's. This URL will be passed to LoadBalancer( my another play application in another machine). Which will decide where to go. if mode=1 then it will send the URL to my PlayApplication1, if mode=2 then it will send the URL to my another PlayApplication2 on another machine and so on.

Comment: Additional Info: if user changes mode=1, Then Application1 will be trigger, if changes to mode=2 then then Application2 will be trigger. Application1 and Apllication2 are completely different from functionality and UI. Application1 is a PlayApplication. Application2 can be a PlayApplication or Symfony or whatever.

Comment: where are you actually using this parameter? in the html templates?

Here is the accepted answer: I couldn't find any inbuild option in play to do that. So i added the mode in every template.


Here is another answer: Create a controller with a @Before method and in this method add your arg

```@Before
public static void setUpTemplate() {
    renderArgs.put("mode", "1");
}
```

In all your controllers, add this Controller as an interceptor with a @With annotation

Comment for this answer: this argument should be viewed in the url like http://localhost:9000/design/reportsList?customer=10&mode=1

Here is another answer: Do you want to access the configuration file from your views? If so, you can do it like this:

```#{if play.Play.configuration.get("yourKey") == '1'}
   ... Do something ...
#{/if}
```

Otherwise, where do your "Additional arguments" come from?

Comment for this answer: the user will type in the url ( any url) or we will receive a url with mode as one argument

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:12/13/11', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<routing><playframework>', 'Title': 'How to add additional argument to all templates in play framework', 'ViewCount': 341, 'id': 8487244, 'user_AboutMe': '<p>Cool.....</p>\n', 'user_AccountId': 268522.0, 'user_DisplayName': 'Arasu', 'user_Reputation': 2058.0, 'user_Views': 238.0, 'user_id': 557329.0}}