Lark - Helper methods


A few Lark-based helper methods which you may want to consider using in blade views.

viewExists

Facades can't currently be used in Roots Sage, this helper method requires a blade view to check whether a view exists or not.

@if(viewExists("flexible.blocks.viewnamehere"))
  @include("flexible.blocks.viewnamehere")
@endif

A handy menu location wrapper of which the return is a collections object. Pass in a location name to get the result.

@php $primaryNavigation = menu_for('primary_navigation'); @endphp

@if ( ! $primaryNavigation->isEmpty())
  @foreach ($primaryNavigation as $menuItem)
    <x-nav-dropdown-link link="{{ $menuItem->url }}"
                         title="{!! $menuItem->title !!}"
                         class="py-10 border-b-1 last:border-b-0"
    />
  @endforeach
@endif

fullAddress

Print the site's full address from global ACF fields found within Theme Settings in the admin panel.

@hasoption('address_1')
  <ul>
    <li>
      {{ fullAddress() }}
    </li>
  </ul>
@endoption

Please continue to the next step - going live