Jump to content

Use of variables to build internal URLs


Recommended Posts

I would like to include some pointers into different text blocks (WYSIWYG or HTML).

Currently, to prevent havinng the absolute URL path hard coded in the HTML text, I would like to use a variable which holds the URL prefix (ie. service name and port).

I browsed mostly the whole documentation, but I did not find a place where variables are listed and how to do that.

Link to comment
Share on other sites

1 hour ago, bernhara said:

I would like to include some pointers into different text blocks (WYSIWYG or HTML).

Currently, to prevent havinng the absolute URL path hard coded in the HTML text, I would like to use a variable which holds the URL prefix (ie. service name and port).

I browsed mostly the whole documentation, but I did not find a place where variables are listed and how to do that.

Hi,

I'm largely guessing what you mean - thus possibly guessing incorrectly. It would make it clearer if you provided more detailed examples of what you want.

My guess:

In PHP something like this might work:

$url = \IPS\Http\Url::external("https://{$service}:{$port}/rest-of-url");

or in a template file (PHTML):

{{$url = \IPS\Http\Url::external("https://{$service}:{$port}/rest-of-url");}}

Then you can use the $url variable in your text/html - either in a template file or else text embedded in your PHP:

<a href="{$url}">Click this</a>

John

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...