Jump to content

Use of variables to build internal URLs


Go to solution Solved by Daniel F,

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

  • 3 weeks later...
On 4/24/2024 at 10:35 AM, BN_IT_Support said:

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.

😏

You are right, my question is not clear enough.

Let me reformulate it in a concrete way.

I would like to get dynamically the amount of members of a given group.

My aim is simple: we have a specific group which holds all the registered privileged members who paid some money in addition of have simply registered. These privileged members can navigate the full web site without any AD and have access to specific services (same notion that  "silver", "gold", ... members).

I simply want to display to all the amount of people who accepted to pay (ie. who accepted to become a privileged member).

And my idea was to create a simple block and use the template language to compute the given amount.

I agree that my initial question was more to request for some help on where to find any documentation. And I wanted to underline that I found no help nor documentation to drive me to the solution.

 

 

Link to comment
Share on other sites

  • Solution

you can get the count of members in a group via \IPS\Member\Group::load(YOURID)->getCount()

 

So to use it in the template, you'll want something like:

{{$members = \IPS\Member\Group::load(4)->getCount();}}

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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