Hi everyone,
I’m currently working on a client project that requires headlines with differently colored segments. This type of headline is required for several layouts in a flexible content field.
The logic in my view is pretty straightforward:
@php
$row_count = get_sub_field('headline');
if (!empty($row_count)) {
$row_count = count($row_count);
}
@endphp
@if(have_rows('headline'))
<h2 class="text-uppercase">
@while(have_rows('headline')) @php the_row() @endphp
@php $color = get_sub_field('color') @endphp
<span class="text-{{ $color }}">@php the_sub_field('headline_segment') @endphp</span>
@if (get_row_index() < $row_count)
<br>
@endif
@endwhile
</h2>
@endif
However, I’d like to take advantage of the way Sage is intended to be used and rather have this kind of code placed in my controller.
Unfortunately, I’m really new to working with controllers and am not quire sure how I would approach this since I assume I would have create a controller for each specific flexible content partial.
I’d really appreciate any hints.