Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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
    Ricky Green
    @rgcouk
    Good morning all :)
    Mathijs Lemmers
    @MathijsLemmers_twitter
    photo_2017-03-30_22-54-56.jpg
    Question incoming...
    I want to have a static homepage with my latest blogposts on it. For some reason, instead of rendering blogposts it renders my homepage as a blogpost on my homepage. I have set my Home as static homepage and have not defined a blog page

    I have a front-page.php with the following code

    <?php
        $context = Timber::get_context();
        $context['post']= new Timberpost();
    
        Timber::render("frontpage.twig", $context);

    and a frontend.twig with the following

    {% extends "index.twig" %}
    
    {% block main %}
        {% include "plugins/posts/overview.twig" ignore missing %}
    {% endblock %}

    Can anybody tell me what I should modify for this to work? It seems like an easy thing to achieve...

    Ricky Green
    @rgcouk
    I'm pretty new to this too, but could you take
        $context['post']= new Timberpost();
    out the frontpage and add it to your single.php file?
    timber/timber#453
    Mathijs Lemmers
    @MathijsLemmers_twitter

    @rgcouk Hi! Sorry for the late response, it was around midnight where I’m living when I posted this, haha. I’ve looking into the Issue on Github and that fix did it for me! So I just pasted

    $data = Timber::get_context();
    $data['page'] = new TimberPost();
    
    $templates = array('page.twig');
    if (is_front_page()){
    
        // get latest three posts
        $args = array(
            'posts_per_page' => 3
        );
        $data['posts'] = Timber::get_posts($args);
    
            // add your twig view to the front of the templates array
           array_unshift($templates, 'my-static-home.twig');
    }
    
    Timber::render( $templates, $data );

    into my front-page.php.

    I don’t really understand it though. Right now I’ve changed the count from 3 to 999 because I want all my posts to show up. Does anyone know a way to simplify this bit of code to achieve the same thing? Thanks in advance!

    Marko Bolliger
    @cannap
    Hi how can i get post.thumbnail.src the description?
    @MathijsLemmers_twitter 0?
    or -1
    not sure
    Ricky Green
    @rgcouk
    it's -1 on a normal wp_query so i should imagine it's the same with timber, @MathijsLemmers_twitter, i'm in the same boat in getting things to work but not understanding the mechanics behind it, i'm taking the don't worry about why it works approach as i've spent too much time trying to figure it out so i'm hoping that will come with more experience.
    I've also started to use github, your able to review older code and see the progress, gives you something to keep you working at a pace when your working on your own.
    Marko Bolliger
    @cannap
    hi any know a template wich uses full woocommerce where i can check on github?
    Ricky Green
    @rgcouk
    https://github.com/rgcouk/Atomic - This is what i'm working on, not saying it's the best as i'm new also.
    Few more hours to go yet.
    Marko Bolliger
    @cannap
    hm does timber not support whole woocomemrce?