• Resolved JB Christy

    (@jbchristy)


    I’m building a new theme based on Timber, a starter theme that allows WordPress template files to be written in Twig.

    Timber handles output in a weird way. It gathers up all the data that might be rendered in a Twig template into a $context variable, then it uses PHP’s ob functions to capture output, then it renders the Twig templates, passing $context to them. Finally, it flushes PHP’s output buffer to actually emit the pages.

    The trouble is that it populates the $context variable with everything, including sidebar content, before it attempts to render any output, and, in particular, before it calls wp_head(). Since this plugin does its work in head, as opposed to filters called by dynamic_sidebar(), it doesn’t get triggered until long after Timber-based themes have captured the output of the sidebars.

    Long term I’d like to suggest that this plugin do it’s work during the processing of dynamic_sidebar() vs. wp_head(), so that the work is done at the time that it’s needed. It is not a best practice to assume that actions are performed in a particular order.

    Short term, do you have any suggestions as to how to use this plugin in themes based on Timber? I could code something completely hack-ish in my theme, like

    if ( class_exists( 'CustomSidebarsReplacer' ) ) CustomSidebarsReplacer::instance()->replace_sidebars();

    but oy, that’s ugly, hack-ish and brittle. Any other thoughts on how I can use this plugin as is?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @jbchristy,

    I hope you’re doing well!

    I’ve forwarded your message to our developers so they could have a closer look at this issue. Please note, our developers’ response time is longer-than-normal compared to support staff response times.

    Once there will be a follow-up, we will update this thread.

    Have a good day and take care!

    Kind regards,
    Nastia

    Thread Starter JB Christy

    (@jbchristy)

    Thank you, Nastia! Since I expect this will be a tricky issue to fix, we’re investigating alternative plugins. We think Cherry Sidebars might work for us – we’re testing it now.

    We’d prefer to use your Custom Sidebars plugin, as it will ease migrating our existing sites to the new theme. Plus, we really like it! So if there is a quick fix that’d be great!

    • This reply was modified 5 years, 1 month ago by JB Christy.

    Hi @jbchristy

    Our developers will look into this but the solution will most likely mean quite significant changes in our plugin’s code and the way it works so it might take some time for them to come up with possible options. We’ll update you here once we get to know more.

    Kind regards,
    Adam

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Doesn’t work with themes based on Timber’ is closed to new replies.