GithubHelp home page GithubHelp logo

Comments (4)

adamtomat avatar adamtomat commented on May 31, 2024

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 return $template at the end of the handleTemplateInclude() method in Lumberjack's WordPressControllersServiceProvider class please, and let us know if that resolves the issue?

Here's a link to that method for reference: https://github.com/Rareloop/lumberjack-core/blob/v4.2.0/src/Providers/WordPressControllersServiceProvider.php#L21

from lumberjack.

mrkkr avatar mrkkr commented on May 31, 2024

Hey! Thanks for your quick response.
This is my first contact with Lumberjack, I decided to use it when my patience for the spaghetti code in WP was over. I just have to do a simple shop based on Woo, so I'm hoping for Lumberjack.

Would you be able to try adding in return $template at the end of the handleTemplateInclude() method in Lumberjack's WordPressControllersServiceProvider class please, and let us know if that resolves the issue?

Unfortunately, nothing happened, Lumberjack still reads from archive.php or index.php.
But I found a temporary solution that works - I created a taxonomy-product_cat.php file with a TaxonomyProductCatController class controller and now reads the data correctly.

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.

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.
I can share my impressions when I finish my shop.

from lumberjack.

adamtomat avatar adamtomat commented on May 31, 2024

@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 template_include which should resolve this issue.

from lumberjack.

jhhazelaar avatar jhhazelaar commented on May 31, 2024

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 Timber::render or even older the_post.

First I've created my own WordPressControllersServiceProvider and replaced the Lumberjack WordPressControllersServiceProvider in de app.php:

'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 controllers.php with an config array with a key exclude_templates:

<?php

return [
    'exclude_templates' => [
        '/subfolder/archive.php',
        '/subfolder/single.php',
    ],
];

This is what's in my own WordPressControllersServiceProvider:

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

from lumberjack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.