Roots Discourse

How implement hero section, correct way

I want to implement Hero section inside header template
I use Sage 10, I’ve never worked with Laravel and that’s why I don’t quite understand how to work with View Composers

How it’s implemented now:

  1. I created a file Fields/Hero.php
    This displays ACF on the desired page

  2. I created file Composers/Hero.php
    This is where I get fields from ACF and pass them to the with() function.
    Also in the array $views I list the blade templates

  3. In the header.blade.php I check if Hero is on and connect the template

  4. In the file hero.blade.php I already get data from Composers/Hero.php and output the layout

Interested in 2 and 3 point, everything is correct here? And how could it be done differently?

1 Like

Any ideas or recommendation?)