Skip to main content
1-Visitor
May 4, 2018
Question

How can I get url parameter in master?

  • May 4, 2018
  • 3 replies
  • 2439 views

Hi,

 

I have a master with a menu and a mashup container. On the top of the master I would show the current page title. Some pages (mashups) have lists of items. If I double click them I jump to a new page with the data of the item. Now I will show "machine xzy" in the top of the master. To get the double clicked item I will use the url parameter.

 

How can I get url parameter in master?

3 replies

1-Visitor
May 5, 2018

Parameters inside the defaults collection don't necessarily have to match a placeholder in the route path. In fact, you can use the defaults array to specify extra parameters that will then be accessible as arguments to your controller, and as attributes of the Request object:

# config/routes.yaml
blog:
 path: /blog/{page}
 controller: App\Controller\BlogController::index
 defaults:
 page: 1
 title: "Hello world!"

Now, you can access this extra parameter in your controller, as an argument to the controller method:

public function index($page, $title)
{
 // ...
}

 Alternatively, the title could be accessed through the  object:

use Symfony\Component\HttpFoundation\Request;

public function index(Request $request, $page)
{
 $title = $request->attributes->get('title');

 // ...
}

 As you can see, the $title variable was never defined inside the route path, but you can still access its value from inside your controller, through the method's argument, or from the Request object's attributes bag.

________________________________________________________________________________________

Also CHeck this out for 

Kickass Proxy | Free Netflix Accounts | Free Movie Sites | Best Radar Detectors 

5-Regular Member
May 9, 2018

Hi @drichter I'm not sure if I get your full use case correct, but have you tried using MediaEntity Service? It includes GetProxyURL with which you can build the URL and pass it to the required widget.

drichter1-VisitorAuthor
1-Visitor
May 9, 2018

This is not relay what i want. I hope this picute can explane what i mean:

flow.png

 

The red box is the master. The dark grey is the menu the light gray box is the content mashup.

In mashine overview I can doubleclick on a item (for example machine). The mashup changed to the machineDetail page. It have a mashup parameter for the double clicked item and in the url you see the parameter of the item.

My problem is that the master does not get the url parameters.

1-Visitor
June 12, 2019

There's no standard way of doing it.

 

You can hack it using javascript on a ExpressionWidget (trigger it onload por instance), something like:

 

 

((location.href.indexOf("&yourParameterName=")>=0)?location.href.slice(location.href.indexOf("&yourParameterName=")+yourParameterName.length).split("&")[0]:"")

 

on your case:

 

((location.href.indexOf("&machineID=")>=0)?location.href.slice(location.href.indexOf("&machineID=")+9).split("&")[0]:"")
1-Visitor
June 12, 2019

Hi @drichter I'm not sure if I get your full use case correct, but have you tried using MediaEntity Service? It includes GetProxyURL with which you can build the URL and pass it to the required widget. G|U|I|D|E|S