-
Notifications
You must be signed in to change notification settings - Fork 34
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
Lumberjack doesn't see archive-{post_type}.php with proper controller class #21
Comments
Hey! We've had somebody else run into this issue once before. It's caused by some inflexibility in the WP core itself, which meant we had to implement the Lumberjack Controller stuff in a particular way. This method relies on the "template_include" filter, which both Lumberjack and WooCommerce both use. In short, due to some of the complexities in Lumberjack, the WooCommerce's "template_include" filter doesn't run. We've put in a ticket into the WP core so in the future we can use something other than "template_include": https://core.trac.wordpress.org/ticket/46652 We would like to work out a patch for this, however we have not done anything with WooCommerce ourselves so it would be great to work with someone to get this tested and resolved. Would you be able to try adding in Here's a link to that method for reference: https://github.com/Rareloop/lumberjack-core/blob/v4.2.0/src/Providers/WordPressControllersServiceProvider.php#L21 |
Hey! Thanks for your quick response.
Unfortunately, nothing happened, Lumberjack still reads from archive.php or index.php.
I am pleased to be able to contribute at least a little to the development of this project by testing it. I hope I won't encounter any more problems and the WP team will fix soon this inflexibility in the WP Core. |
@mrkkr Glad you found a work around. Thank you for giving that a test. We are currently exploring an alternative approach to the way we use |
Hi, I think I ran in the same problem with another plugin. The plugin has its own subfolder in the theme with an archive and single template. This caused a problem with converting the template to a controller. I wanted a way to disabled templates to be converted to controllers so that we can use old school First I've created my own 'providers' => [
Rareloop\Lumberjack\Providers\RouterServiceProvider::class,
// Rareloop\Lumberjack\Providers\WordPressControllersServiceProvider::class,
App\Providers\WordPressControllersServiceProvider::class,
Rareloop\Lumberjack\Providers\TimberServiceProvider::class,
Rareloop\Lumberjack\Providers\ImageSizesServiceProvider::class,
Rareloop\Lumberjack\Providers\CustomPostTypesServiceProvider::class,
Rareloop\Lumberjack\Providers\MenusServiceProvider::class,
Rareloop\Lumberjack\Providers\LogServiceProvider::class,
Rareloop\Lumberjack\Providers\QueryBuilderServiceProvider::class,
Rareloop\Lumberjack\Providers\SessionServiceProvider::class,
Rareloop\Lumberjack\Providers\EncryptionServiceProvider::class,
// Application Providers
App\Providers\AppServiceProvider::class,
], Then I've create a new config file named <?php
return [
'exclude_templates' => [
'/subfolder/archive.php',
'/subfolder/single.php',
],
]; This is what's in my own <?php
namespace App\Providers;
use Rareloop\Lumberjack\Providers\WordPressControllersServiceProvider as LumberjackWordPressControllersServiceProvider;
use Rareloop\Lumberjack\Facades\Config;
use Stringy\Stringy;
class WordPressControllersServiceProvider extends LumberjackWordPressControllersServiceProvider
{
public function handleTemplateInclude($template)
{
if (in_array(Stringy::create($template)->removeLeft(get_template_directory()), Config::get('controllers.exclude_templates'))) {
return $template;
}
parent::handleTemplateInclude($template);
}
} I think this is an easy way to disabled some templates to be converted to controllers. Hope this helps. |
What are the steps to reproduce this issue?
What happens?
Lumberjack doesn't see archive-product.php, it is looking for archive.php or index.php. It's not in line with the templatee hierarchy (please look at https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types)
What were you expecting to happen?
Lumberjack should looking for archive-product.php and ArchiveProductController class.
What versions of software are you using?
Operating System: Win10, Apache (XAMMP)
PHP Version: 7.2
Lumberjack Version: latest
The text was updated successfully, but these errors were encountered: