How can I set ACF variables inside Laravel's blade template?

Try to use a single line or multi line declaration for ACF VARIABLES, but doesn’t work. The page would supper slow and not even be showing.

Any ideas? Is about the Laravel version that using on Sage 9?

Also for Godaddy PHP 7.2, would support the latest Sage 9?

@if (have_rows('test')) 
 @while (have_rows('test')) @php(the_row())

      $myVar 		= get_sub_field('$myVar');
      $anotherVar 	= get_sub_field('$anotherVar');

    <p>{{ $myVar }}</p>
    <p>{{ $anotherVar }}</p>


Sage 9 just requires >= PHP 7.1.3, so 7.2 should work fine.

Sage no longer supports shorthand @php statements. You need the @endphp. On the second line of the example make the following change:

+ @php the_row() @endphp
- @php(the_row())

Best practice would be to separate this logic into a controller. You can use Sage’s data filter or Controller to do this. If you choose to use the data filter, you may need to remove soberwp/controller from your project (composer.json).

Yes, this would have been a due to Sage upgrading the Laravel version.

I know for a fact it does.


adding @endphp works. I like to keep my variables into each template, but I for sure would check the data filter. thanks for that!

1 Like

Come up with one question, how about if I need to use the ACF repeater fields?

How do I set the data on the Filter?

$data['test_repeat'] = have_rows('test_repeat');


@if {{ $test_repeat }}
  @while {{ $test_repeat }} @php the_row() @endphp

But how about if I also need to use the get_field('test_repeat'), do I need to input different $data variable?


Forgive me if my ACF is rusty — I’ve been using Carbon Fields for that last few months.

ACF’s have_rows() isn’t the value, it returns a boolean; it is just to check if the field has rows.

What you want is:

$data['test_repeat'] = get_field('test_repeat');

This should give you an array called $test_repeat in your template.

Use the following to test it and to understanding the structure of the array:

@php print_r($test_repeat); @endphp

I’m not going to dive into any advanced stuff — others can chime in with that. But if you take a look around the forum there are a lot of posts that are similar to this.

1 Like

alright, thanks so much!!!

just found out if I remove the soberwp/controller on the composer.json, that gave me this error:

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in 

And if I am not removing it, that the data filter doesn’t work.

Not sure why???

Read the error:

Class 'App' not found

This means that you’re trying to call something from the App class that PHP can’t find, so look through your code for something that’s trying to call something on App. If this is a fresh Sage installation, chances are it’s App::siteName().

1 Like

It is the {!! App::title() !!}.

It is because of the soberwp/controller removed that cause missing some funcations, but if I do not remove it which the DATA Filter won’t pass the variables.

If there is no perfect way to use both, I think I gonna give up the controller.
Then should I just not use APP:: and can I remove the entire APP/controller folder?

  "require": {
    "php": ">=7.1",
    "composer/installers": "~1.0",
    "illuminate/support": "~5.6",
    "roots/sage-lib": "~9.0.1"

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in /Applications/MAMP/htdocs/test-wp/wp-content/uploads/cache/4fc948931e324a50d1bd98f57bff15caf3ea89d0.php:4 Stack trace: #0 /Applications/MAMP/htdocs/test-wp/wp-content/themes/sk-theme/vendor/illuminate/view/Engines/PhpEngine.php(43): include() #1 /Applications/MAMP/htdocs/test-wp/wp-content/themes/sk-theme/vendor/illuminate/view/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Applications/M...', Array) #2 /Applications/MAMP/htdocs/test-wp/wp-content/themes/sk-theme/vendor/illuminate/view/View.php(142): Illuminate\View\Engines\CompilerEngine->get('/Applications/M...', Array) #3 /Applications/MAMP/htdocs/test-wp/wp-content/themes/sk-theme/vendor/illuminate/view/View.php(125): Illuminate\View\View->getContents() #4 /Applications/MAMP/htdocs/test-wp/wp-content/themes/sk-theme/vendor/illuminate/view/View.p in /Applications/MAMP/htdocs/test-wp/wp-content/uploads/cache/4fc948931e324a50d1bd98f57bff15caf3ea89d0.php on line4`