Sage 10 only work with ACF PRO?

As far I remember, Sage 9 work with ACF. Do Sage 10 work only with ACF PRO?

I’ve tried to make it work using acf-composer, the fields showed in WordPress customize page, but no luck getting fields in .blade.php files.

Sage should not care what version of ACF you’re using since it doesn’t integrate with ACF at all.

What is the specific problem you’re running into? What are you attempting to do, and how is it failing?

Then I think I don’t really understand how View Composers work.

Here are my files:

acf.php placed in config/

Path:

app/Fields/ContentFrontPage.php

<?php

namespace App\Fields;

use Log1x\AcfComposer\Field;

use StoutLogic\AcfBuilder\FieldsBuilder;

class ContentFrontPage extends Field

{

    /**

     * The field group.

     *

     * @return array

     */

    public function fields()

    {

        $frontPage = new FieldsBuilder('Front Page ACF');

        $frontPage

            ->setLocation('page_type', '==', 'front_page');

        $frontPage

            ->addText('hero_text_field_first', [

                'label' => 'Hero First Text Field',

                'instructions' => '',

                'required' => 0,

                'wrapper' => [

                    'width' => '',

                    'class' => '',

                    'id' => '',

                ],

                'default_value' => '',

                'placeholder' => '',

                'prepend' => '',

                'append' => '',

                'maxlength' => '',

            ]);

        $frontPage

            ->addText('hero_text_field_second', [

                'label' => 'Hero Second Text Field',

                'instructions' => '',

                'required' => 0,

                'wrapper' => [

                    'width' => '',

                    'class' => '',

                    'id' => '',

                ],

                'default_value' => '',

                'placeholder' => '',

                'prepend' => '',

                'append' => '',

                'maxlength' => '',

            ]);

        $frontPage

            ->addTextarea('hero_textarea_field', [

                'label' => 'Hero Textarea Field',

                'instructions' => '',

                'required' => 0,

                'wrapper' => [

                    'width' => '',

                    'class' => '',

                    'id' => '',

                ],

                'default_value' => '',

                'placeholder' => '',

                'maxlength' => '',

                'rows' => '',

                'new_lines' => '', // Possible values are 'wpautop', 'br', or ''.

            ]);

        return $frontPage->build();

    }

}

If I use {{ !hero_text_field_first }} in content-front-page.blade.php, I get:

“Undefined variable: hero_text_field_first”

As a side note,
wp acorn vendor:publish --provider="Log1x\AcfComposer\Providers\AcfComposerServiceProvider"
and
wp acorn acf:field Example

throw me this error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect()

None of the things you’ve posted here are View Composers. What do you mean by this?

acf-composer and acf-builder are only for building field definitions–they have nothing to do with getting field values and/or displaying them on the frontend.

In order to get your field value in your blades, you would need to get the value–i.e. with get_field().

Do you have a full development environment configured (i.e. a MySQL server, a functioning WordPress installation, etc)? That error suggests that you’re running those commands in a context where WP-CLI isn’t able to find a viable WordPress install and/or connect to your database.

My mistake was using:
{{ $hero_text_field_first) }}
instead of:
{{ get_field('hero_text_field_first') }}
in blade files.

Now everything works as expected.

Thanks to this I realize the mistake and I can’t believe I didn’t try it before, Thank you so much!

About the development environment, I use Local to config the back-end. Looks like everything works fine except I was constrained to manually import acf.php because of this error.

This topic was automatically closed after 42 days. New replies are no longer allowed.