Hello!
In sage 9 I use directives for show data I use a lot ACF (yeah yeah ) but I want to use Composer in Sage 10.
I think I have understood how to parse data in my homepage but to show data in my header sections with other post type I have success (thanks directives ) to show for example my logo, but my second logo not display, and I don’t know why…
I use Acorn 2.0.5
My code :
/** app/View/Composers/Header.php */
namespace App\View\Composers;
use Roots\Acorn\View\Composer;
class Header extends Composer
{
/**
* List of views served by this composer.
*
* @var array
*/
protected static $views = [
'sections.header',
];
/**
* Data to be passed to view before rendering.
*
* @return array
*/
public function with()
{
return [
'logo' => $this->logo(),
'logowhite' => $this->logowhite(),
];
}
public function logo()
{
return wp_get_attachment_image(get_field('logo'), 'large', false, array('class' => 'logo-agir'));
}
public function logowhite()
{
return wp_get_attachment_image(get_field('logo_blanc'), 'large', false, array('class' => 'logo-agir-logo-white'));
}
}
My blade template :
ressources/views/sections/header.blade.php
<header class="warp">
<div class="container-fluid g-6">
<div class="row">
<div class="col-lg-12 d-flex align-items-center justify-content-between">
@query([
'post_type' => 'options',
'post__in' => array(18)
])
@posts
<a class="brand" href="{{ home_url('/') }}">
{!! $logo !!}
{!! $logowhite !!}
</a>
@endposts
My $logowhite not showing and is empty with a var_dump but if I replace this var with
<header class="warp">
<div class="container-fluid g-6">
<div class="row">
<div class="col-lg-12 d-flex align-items-center justify-content-between">
@query([
'post_type' => 'options',
'post__in' => array(18)
])
@posts
<a class="brand" href="{{ home_url('/') }}">
{!! $logo !!}
@php echo wp_get_attachment_image(get_field('logo_blanc'), 'large' ); @endphp
</a>
@endposts
All working fine, so where I’m wrong and if you are tips for make post_type in my composer?
Thanks for your time, and thanks to Team Roots for this wonderful work!!