sage-acf-wp-blocks icon indicating copy to clipboard operation
sage-acf-wp-blocks copied to clipboard

Fixed error in Sage9 with multiple block folders

Open blift opened this issue 4 years ago • 4 comments

New feature with multiple folders in sage9 throw the critical error with wrong file paths. Foreach loop for filter "sage-acf-gutenberg-blocks-templates" mixed wrong path with block files and return the error. I've added new filter "sage-acf-gutenberg-blocks-other-templates" for other folders. This filter can be override in filters.php by new array. (readme updated with example). Default filter "sage-acf-gutenberg-blocks-templates" return only 'views/blocks' if developer not decide to use more block folders.

Not tested with sage10 but, the variable $view return the same result as before

blift avatar Oct 29 '20 20:10 blift

Duplicate of #51

robmeijerink avatar Oct 30 '20 08:10 robmeijerink

Not exactly, previous request with bug fixes not working. Foreach loop return each blocks to all folders and return error because can't find duplicate blocks in different location.

blift avatar Oct 30 '20 08:10 blift

Hi @blift, thank you for your feedback. I had another look at my code. If I understand you correctly, you ran into an issue when having a duplicate block in a different location? So for example /blocks/banner.blade.php and /blokks/banner.blade.php? Interesting, I did not test that scenario. 😊 In this case I see that both blocks render in the page.

However, I see the same issue / result happening in your solution when using your filter in this scenario:

add_filter('sage-acf-gutenberg-blocks-other-templates', function ($folders) {
    $folders[] = 'views/blokks';
    return $folders;
});

I don't think that having a different filter with the same purpose fixes the issue in this scenario. Am I overlooking something in your PR? 🤔

robmeijerink avatar Nov 02 '20 19:11 robmeijerink

Hi @robmeijerink, thanks for new commit and code check. No that wasn't issue with duplicate the same block in different location. Previous pull #51 mixed wrong path to folder with blocks. I've checked your fixed commit, added yesterday, and works fine.

blift avatar Nov 03 '20 08:11 blift