Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Steve Pfisterer
    @stevep
    ob_get_clean() without ? Sorry my formatting got messed up
    Lukas Gächter
    @gchtr
    So that would be $context['minicart'] = ob_get_clean();, without the ob_end_clean(), I guess?
    Steve Pfisterer
    @stevep
    Maybe... I should have prefaced it with "trying using". Though if it was happening before it probably isn't the issue
    Steve Pfisterer
    @stevep
    Never mind I think @gchtr you're exactly right with your original solution. I think this issue with random 1s and 0s is somewhere else. I was googling the issue without reading, first thing on the morning ( for me )
    Ricky Green
    @rgcouk
    These are the links
    Lukas Gächter
    @gchtr
    You are resetting $context in https://github.com/rgcouk/Atomic/blob/ba96c64a6a3d7ef7ba38ee9ee4c4571d249eb2d9/index.php#L16. The ob_start(); part should come after you use get_context(). Maybe the 0 appears because when you use {{ mini-cart }} in https://github.com/rgcouk/Atomic/blob/ba96c64a6a3d7ef7ba38ee9ee4c4571d249eb2d9/templates/blocks/header.twig#L26, it doesn’t exist. Also, I wouldn’t use variable names with hyphens. Use minicart or mini_cart instead.
    Steve Pfisterer
    @stevep
    ahh yes, I think {{ mini-cart }} is subtracting null from null and echoing 0
    Ricky Green
    @rgcouk
    Yes, it was defiantly that, it's gone but the cart still not showing.
    Steve Pfisterer
    @stevep
    what did you change it to?
    Ricky Green
    @rgcouk
    minicart
    Steve Pfisterer
    @stevep
    also as @gchtr said, you need to move $context = Timber::get_context(); above where you’re grabbing the mini cart… your setting $context['minicart'] = ob_get_contents(); and then blowing away the $context variable when you do $context = Timber::get_context(); after
    Lukas Gächter
    @gchtr
    $context = Timber::get_context();
    
    ob_start();
    include ('woocommerce/cart/mini-cart.php');
    $context['minicart'] = ob_get_contents();
    ob_end_clean();
    
    $context['posts'] = Timber::get_posts();
    Ricky Green
    @rgcouk
    I've also do that.
    done*
    How do i copy code with syntax highlighting like that please
    'code'
    '''
    Lukas Gächter
    @gchtr
    It has to be backticks
    Ricky Green
    @rgcouk
    $context = Timber::get_context();
    
    ob_start();
        include ('woocommerce/cart/mini-cart.php');
        $context['minicart'] = ob_get_contents();
    ob_end_clean();
    
    $context['posts'] = Timber::get_posts();
    
    $templates = array( 'pages/index.twig' );
    
    if ( is_home() ) {
        array_unshift( $templates, 'pages/home.twig' );
    }
    Timber::render( $templates, $context );
    Steve Pfisterer
    @stevep
    if you set $context['minicart'] = 'something else'; does it output something else?
    can see if the issue is with the include or something else
    Ricky Green
    @rgcouk
    Okay, will try.
    Nope, nothing displays still.
    Steve Pfisterer
    @stevep
    is it possible that page.php is getting executed instead of index.php? becuase minicart isn’t added to the context in page.php
    or single.php
    youd probably want to add it to all wordpress template php files
    Ricky Green
    @rgcouk
    Argh!! :D
    Yes, it worked, then i had to change back from something else, i've git a fatal error now, undefined method WC_proudct_simple
    Steve Pfisterer
    @stevep
    It's rendering for me but that method looks like it has a spelling error
    Ricky Green
    @rgcouk
    Hmm, doesn't render for me, strange
    Steve Pfisterer
    @stevep
    It does on mobile but not desktop
    Ricky Green
    @rgcouk
    That's strange, what do you think could cause that?
    Steve Pfisterer
    @stevep
    Not sure but it does seem like a clue
    Ricky Green
    @rgcouk
    Well, im not sure if it's mobile or if it's when you add something to the basket because i've just opened it up on my phone and added a product to the basket to see if the cart updated and it gave me that error.
    Did you add anything to the cart ?
    Yep, it's something when the customer add's i've gone incognito and it rendered the website for me.
    $product_name  = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
    This is the line of code on 41.
    Tomi
    @tnottu
    Does anyone have a good way to add post counts to year and month titles with TimberArchives?
    Ricky Green
    @rgcouk
    @stevep I can't find no answers for this, any idea how i could find the problem?
    Ricky Green
    @rgcouk
    @stevep @gchtr Thanks for your help on that part, i've used a function to call the php in and then used do_action, it seems to work.
    Tomi
    @tnottu
    could someone give some advice (or links to tutorial etc) how to set up Timber for development and testing on my computer? i'm unfamiliar with php testing workflows but i really should learn the basics at least.
    what i've done/tried so far:
    1. installed php, composer and phpunit globally
    2. ran composer install in Timber project directory
    3. ran phpunit in Timber project directory. that gives an error message require_once(/tmp/wordpress-tests-lib/includes/functions.php): failed to open stream: No such file or directory in /Users/tomi/git/timber/tests/bootstrap.php on line
    i suppose i'm missing something very basic, but not quite sure where to start troubleshooting
    oh wait, now i found the testing info in the wiki... how did i miss that..
    Tomi
    @tnottu
    ok, got it to work i think