Hello
…sorry, this is maybe a basic php/blade question, but I can’t find a solution around. I’m tryng to figure out how to use the @isset (or an alternative) to display a data value from a controller custom loop.
Say this is my custom loop (in FrontPage.php controller):
public static function latestItemsLoop()
{
$args = array(
'post_type' => 'items',
'posts_per_page' => 6,
);
$index_items = get_posts($args);
return array_map(function ($post) {
return [
'itemTitle' => apply_filters('get_the_title', $post->post_title),
[...etc...]
];
}, $index_items );
}
Now in the view.blade file Id’ like to use something like this:
@foreach(FrontPage::latestItemsLoop() as $indexItem)
@isset( $indexItem['itemTitle'] )
<h4>{!! $indexItem['itemTitle'] !!}</h4>
@endisset
@endforeach
…or maybe an “if” condition like (semantically) “if !isnot set” or “if !isnot empty”
I’ve found the @isset in Laravel Blade documentation, but now I don’t know how to deal with Sage 9 views {{!! variable !!}} data