yondaimehokage
yondaimehokage

Reputation: 253

SilverStripe - Template Variable Throwing Error

I have a really basic function that I started. I began very simple with in code/Page.php:

public function createGreeting() {
    return 'hi';
}

In my Page.ss template, I have the variable: <% $createGreeting %>

Yet, this is killing the page. I checked the error logs, and it is showing:

PHP message: PHP Warning:  Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488" while reading upstream, client: 31.210.102.114, server: 52.90.93.59, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:" 2017/06/12 12:34:50 [error] 1730#0: *6682 FastCGI sent in stderr: "PHP message: PHP Warning:  Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488

Any idea what could be causing this? If I remove that line from Page.ss, the page loads perfectly fine.

Upvotes: 1

Views: 78

Answers (1)

Simon Erkelens
Simon Erkelens

Reputation: 762

You shouldn't wrap the variable in a <% %> block, but rather, just call it.

Upvotes: 6

Related Questions