BaronGrivet BaronGrivet - 1 year ago 78
PHP Question

How to use a different protocol with $AbsoluteLink in Silverstripe

In the Silverstripe templating syntax

returns the full URL of a page/object, including the protocol and host:

I want to be able to call a full URL with a different protocol:


What is the best way to achieve this?

Answer Source

Make a new getter function on your page:

public function WebcalLink() {
    $absolute = $this->AbsoluteLink();
    $webcal = str_replace(Director::protocol(), "webcal://", $absolute);
    return $webcal;

You can call it from your template using $WebcalLink

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download