Question

I am trying to render the server name in order to render a full path to an image in a OG tag. When I put the var in the @section, it echo server , not the value.

<?php  $server = $_SERVER['SERVER_NAME'];  ?>
@section('og-image',  '{{$server}}/assets/img/activities/path-to-image.jpg')

How can I get the value of the server, or a full path to this image?

Was it helpful?

Solution

Can't you use:

@section('og-image', URL::to('/').'/assets/img/activities/path-to-image.jpg')

?

But you have access to those variables by using:

Request::server('SERVER_NAME');

So it would be:

@section('og-image', 'http://' . Request::server('SERVER_NAME') . '/assets/img/activities/path-to-image.jpg')

OTHER TIPS

You don't need {{ ... }} when passing parameters to @section or @extends. They are special statements that are parsed differently.

Otherwise you would put {{}} also in the if statements, but you don't :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top