cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How can I get url parameter in master?

drichter
14-Alexandrite

How can I get url parameter in master?

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?

5 REPLIES 5

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 

supandey
19-Tanzanite
(To:drichter)

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.

drichter
14-Alexandrite
(To:supandey)

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.

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]:"")

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

Top Tags