Hi @rphillips2020,
Thanks a lot for using Block Lab, and sorry for the delay.
I have successfully changed the template path to my plugin, but the associated Block CSS file doesn’t load.
Is that by using the filter block_lab_template_path ? https://github.com/getblocklab/block-lab/blob/9daea7770c439fdc04437f870f9d8d5e521fbccc/php/class-util.php#L106
Hi,
Sorry for the delay in getting back. Yes, I am using this code –
`add_filter( ‘block_lab_template_path’, function( $path ) {
unset( $path );
return __DIR__;
} );
I found it online and it works to move the template to my plugin, but the block.css file is not found. On inspection, it seems to be missing the slashes out of the CSS link.
https://www.newleioc.dev.ccwp-contentpluginsleioc-events-templates/blocks/ent-details/block.css?ver=0.0.2
Any help will be gratefully received.
Thanks
Hi @rphillips2020,
Sorry for the delay.
Your use of the filter looks right.
1. Does the block.css file load when the filter isn’t used? (it’ll look for it in the theme)
2. Does replacing return __DIR__; with return dirname( __FILE__ ); help?
If Xdebug is enabled, it be really helpful if you’d be able to find the value of __DIR__ inside that filter.
Or maybe with:
add_filter( 'block_lab_template_path',
function( $path ) {
unset( $path );
var_dump( __DIR__ );
}
);
Thanks, and sorry for the delay.
Hi
I got the var_dump from the filter, this what it gave me –
C:\Users\Roger\Sites\www.newleioc.dev.cc\wp-content\plugins\leioc-events-templates\leioc-events-templates.php:70:string 'C:\Users\Roger\Sites\www.newleioc.dev.cc\wp-content\plugins\leioc-events-templates' (length=82)
It shows the correct file path to my plugin.
When I remove the filter and add the block to my Theme folder it finds the Block.Css file correctly.
I am happy to enqueue the Block CSS file, but I wasn’t sure if this was correct behaviour from the Block Lab plugin. Thanks for your time with this
Hi @rphillips2020,
Thanks for pasting the var_dump.
Sorry, I don’t know why the stylesheet href is printed as https://www.newleioc.dev.ccwp-contentpluginsleioc-events-templates/blocks/ent-details/block.css?ver=0.0.2″
It might have something to do with the backslashes in the __DIR__, as opposed to forward slashes in a Unix environment.
Sorry I can’t be more helpful, and thanks a lot for using Block Lab.