Snippets

Evgeni Dimitrov Implementing Related Title, Related Image and Excerpt fields

Created by Evgeni Dimitrov last modified
@php
$tags = $_page -> tags;
$related = PagesTools::getRelatedByTag($tags, true , 3);
@endphp
    <p>
        @if(count($related))
            @foreach ($related as $a)
              @php $previewImage = MediaTools::getImage($a->preview_thumb_id); @endphp
                <a href="/{{$a -> url }}">
                    @if ($previewImage)
                        <img data-interchange="[{{$previewImage->original_filename}}, small]">
                    @else
                        <img class="logo" src="/resources/themes/mytheme/assets/images/default_thumb.jpg">
                    @endif
                    @if ($a -> related_title != '')
	                    <span class="related_title">{{ $a->related_title }}</span>
                    @else
	                    <span class="page_title">{{ $a->name }}</span>
                    @endif
                    @if ($a -> excerpt != '')
                       <span class="excerpt">{{ $a->excerpt }}</span>
                    @endif
                </a>
          @endforeach
    @endif
</p>

Comments (0)