Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to v0.6 leads to error #52

Open
djmtype opened this issue Oct 13, 2020 · 7 comments
Open

Updating to v0.6 leads to error #52

djmtype opened this issue Oct 13, 2020 · 7 comments

Comments

@djmtype
Copy link

djmtype commented Oct 13, 2020

After updating to sage-acf-wp-blocks from v0.5 to v0.6, WordPress throws an error. I haven't changed any of my blocks' syntax or location.

I also tried removing this block from my directory, but then I got the same error for the next block.

All my ACF blocks reside in ./resources/views/blocks directory like the sage-acf-gutenberg-blocks.php states

Fatal error: Uncaught InvalidArgumentException: View [views.blocks.alert] not found. in /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/illuminate/view/FileViewFinder.php:137 Stack trace: #0 /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/illuminate/view/FileViewFinder.php(79): Illuminate\View\FileViewFinder->findInPaths('views.blocks.al...', Array) #1 /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/illuminate/view/Factory.php(128): Illuminate\View\FileViewFinder->find('views.blocks.al...') #2 [internal function]: Illuminate\View\Factory->make('views.blocks.al...', Array, Array) #3 /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/roots/sage-lib/Template/Blade.php(138): call_user_func_array(Array, Array) #4 /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/roots/sage-lib/Template/Blade.php(58): Roots\Sage\Template\Blade->__call('make', Array) #5 /Users/scottrod/Sites/maridose/wp-content/themes/maridose/app/helpers.php(55): Roots\Sage\Template in /Users/scottrod/Sites/maridose/wp-content/themes/maridose/vendor/illuminate/view/FileViewFinder.php on line 137

My block

{{--
  Title: Alert
  Category: formatting
  Icon: megaphone
  PostTypes: page post
  SupportsAlign: false
  SupportsMode: true
  SupportsMultiple: true
  Mode: edit
--}}


@php
$classes = '';
$alert_class = '';
$alert_color = get_field('alert_color');
$alert_content = get_field('alert_content')
@endphp

@if( !empty($block['className']) ) 
    @php $classes .= sprintf( ' %s', $block['className'] ) @endphp
@endif

@if($alert_color == 'primary')
@php $alert_class = 'alert-primary' @endphp
@elseif ($alert_color == 'secondary')
@php $alert_class = 'alert-secondary' @endphp
@elseif ($alert_color == 'default')
@php $alert_class = 'alert-default' @endphp
@endif

<section class="alert {!! $alert_class !!} {!! $classes !!}">

<div class="container max-width-lg flow-xs-y">
		{!! $alert_content !!}
	</div>
	<!-- /.container -->

</section>
@speakerbug
Copy link

Just an FYI this is actually already opened as an issue #50 and there's a fix as a pull request #51 but it's been sitting for almost two weeks now.

@blift
Copy link

blift commented Oct 29, 2020

Hi I have aded pull request with fixed error, please verify

@robmeijerink
Copy link
Contributor

@MWDelaney Some people are facing issues in Sage 9. Any chance you can merge the PR that fixes this?

@blift
Copy link

blift commented Oct 30, 2020

@MWDelaney and @robmeijerink please verify pull request #51 before merge, in my case still it not working on sage 9, I've added #53 pull request with update, but not tested with sage 10. The path result is the same in sage_blocks_callback method line 221, so should work properly.

@syclone
Copy link

syclone commented Dec 3, 2020

Hi, I just installed this plugin and got the same error with v0.6. I decided to try v0.5 after reading through these issues and it worked fine. For anyone who is like me and looking for a workaround, v0.5 did the trick.

So just install it like so:

composer require mwdelaney/sage-acf-gutenberg-blocks:0.5

@tombroucke
Copy link
Contributor

tombroucke commented Dec 8, 2020

I have created a pull request that fixes this issue. In the meantime, you can fix the issue by updating the template() function in helpers.php:

function template($file, $data = [])
{
    if ( ! file_exists( $file ) && strpos( $file, 'views/blocks/' ) !== false ) {
         $file = locate_template( $file );
    }
    return sage('blade')->render($file, $data);
}

EDIT: my original temporary fix caused \App\template($template) to break. I added an extra condition strpos($file, 'views/blocks/') !== false for this. My pull request to fix this problem doesn't need modification.

@joshuafredrickson
Copy link

This is fixed in 0.7.

brianjohnhanna added a commit to stirling-brandworks/slab that referenced this issue Jul 27, 2021
brianjohnhanna added a commit to stirling-brandworks/slab that referenced this issue Jul 30, 2021
* Setup fields builder and front-page, page and component field templates

* Fix bug in Sage ACF Blocks

MWDelaney/sage-acf-wp-blocks#52 (comment)

* Update accordion and tab components and blocks

* Add blocks config file

* Add automatic registration of blocks connected to component fields

* Add correct version of sage blocks plugin

* Add additional components and refactor existing

* Add options page

* Update filters, add display_sidebar

* Add default BS4 gravity forms styling

* Include baseline swiper styles

* Refactor default layouts and templates, add kitchen sink

* Update swiper language to represent carousels/sliders

* Update components and kitchen sink

* Add link for sage acf block fix

* Remove duplicate footer element

* Add CLI stubs

* Add CLI script for insering dummy data into kitchen sink template

* Add default card imge style

* Update swiper styles

* Update layout of kitchen sink page

* Remove $test variable

* Refactor card field structure

* Programatically add a menu via demo CLI script

* Add alert component and refactor quicklinks

* Remove block registration and specify details in comment

See #11 for more info

* Update default page settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants