inkredible Posted March 15, 2017 Posted March 15, 2017 I want to build a dynamic URL inside of template, which looks similiar to this: <a href='{url="app=botuserpanel&module=userpanel&controller=userpanel{{if $tab->area}}&area={$tab->area}{{endif}}"}'></a> Because of my if expression it won't build the URL correctly, the result looks like: <a href="{url="app=botuserpanel&module=userpanel&controller=userpanel&area=sessions"}"></a> . Is there a way to build the URL correctly with my IF expression? For example is it possible to build the URL string upfront (but still inside of my template), pass that to {url=} so that it will work?
bfarber Posted March 15, 2017 Posted March 15, 2017 There's more than one way to handle this, but one solution would be {{$url = \IPS\Http\Url::internal( components ... );}} {{if $tab->area}} {{$url = $url->setQueryString( 'area', $tab->area );}} {{endif}}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.