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

Fixed error in Sage9 with multiple block folders #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

blift
Copy link

@blift blift commented Oct 29, 2020

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 added 2 commits October 29, 2020 21:15
Fixed error issue with wrong filter template folders in sage9. 
Added new filter sage-acf-gutenberg-blocks-other-templates for adding new folders as array in filters.php.
Added sage-acf-gutenberg-blocks-other-templates filters, other folder add as array
@robmeijerink
Copy link
Contributor

Duplicate of #51

@blift
Copy link
Author

blift commented Oct 30, 2020

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.

@robmeijerink
Copy link
Contributor

robmeijerink commented Nov 2, 2020

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? 🤔

@blift
Copy link
Author

blift commented Nov 3, 2020

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.

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

Successfully merging this pull request may close these issues.

2 participants