문제

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?

도움이 되었습니까?

해결책

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')

다른 팁

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 :-)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top