MWDelaney / sage-acf-wp-blocks

Composer library for generating ACF Gutenberg blocks from templates. Intended for use with Roots/Sage (http://roots.io)
346 stars 66 forks source link

No Block Types Exist #47

Closed jasperf closed 3 years ago

jasperf commented 3 years ago

I added the plugin, added the example data to block.blade.php inside resources/views/blocks/testimonial and added real block data to testimonial.blade.php in the same directory. But now when I add a new field in Advanced Custom Fields I am told no block type exists? What am I missing here?

jasperf commented 3 years ago

Realized I did not need an extra block.blade.php. Tried without it and testimonial inside the blocks directory instead of a sub directory. Content is as in README.md example:

{{--
  Title: Testimonial
  Description: Customer testimonial
  Category: formatting
  Icon: admin-comments
  Keywords: testimonial quote
  Mode: edit
  Align: left
  PostTypes: page post
  SupportsAlign: left right
  SupportsMode: false
  SupportsMultiple: false
  EnqueueStyle: styles/style.css
  EnqueueScript: scripts/script.js
  EnqueueAssets: path/to/asset
  Preview: true
  PreviewImage: path/to/my/block/preview.jpg
--}}

<blockquote data-{{ $block['id'] }} class="{{ $block['classes'] }}">
  <p>{{ get_field('testimonial') }}</p>
  <cite>
    <span>{{ get_field('author') }}</span>
  </cite>
</blockquote>

<style type="text/css">
[data-{{$block['id']}}] {
  background: {{ get_field('background_color') }};
  color: {{ get_field('text_color') }};
}
</style>

Still I am seeing no block types exist

Screen Shot 2020-09-14 at 5 35 20 AM

inside the Advanced Custom Fields` Fields builder under location. So I must be missing something here. But what?

NB Did see Undefined function 'App\template'.intelephense(1010) and Undefined function 'App\asset_path'.intelephense(1010) inside web/app/themes/ventus/vendor/mwdelaney/sage-acf-gutenberg-blocks/sage-acf-gutenberg-blocks.php

NBB

I am loading ACF 5.9.1 inside my theme form filters.php using

**
 * ACF Path Filter
 * 
 * Customize Advanced Custome Fields path
 * 
 * @link https://www.advancedcustomfields.com/resources/acf-settings/
 * @param string $path
 * 
 */ 
add_filter('acf/settings/path', __NAMESPACE__. '\my_acf_settings_path');

function my_acf_settings_path( $path ) {

    // update path
    $path = get_stylesheet_directory() . '/acf/';

    // return
    return $path;

}

/**
 * ACF Directory Filter
 * 
 * Customize Advanced Custome Fields directory
 * 
 * @link https://www.advancedcustomfields.com/resources/acf-settings/
 * @param string $dir
 */ 
add_filter('acf/settings/dir', __NAMESPACE__ . '\my_acf_settings_dir');

function my_acf_settings_dir( $dir ) {

    // update path
    $dir = get_stylesheet_directory_uri() . '/acf/';

    // return
    return $dir;

}

// Hide ACF field group menu item
//add_filter('acf/settings/show_admin', '__return_false');

/**
 * Include ACF Filter
 * 
 * Include Advanced Custom Fields plugin located in our Sage theme
 * 
 */
include_once( get_stylesheet_directory() . '/acf/acf.php' );
jasperf commented 3 years ago

When I use the Advanced Custom FIelds as a must-use plugin mu-plugins the blocks do load. And I could require Pro using composer installer and adding a repository and including key to .env from Bedrock. Just not from Sage this way.So it seems if I load it form the theme using filters.php it hooks into too late. Adding it as a must use plugin on the other hand does load on time.

LazyRecon commented 2 years ago

if i load acf from theme folder like specified here blocks are not loaded. I move move it to plugin folder.