Sage 9 Wrapper

Hi,

I’ve started playing with Sage 9 and I’ve seen that the SageWrapping was completely rebuilt. I’ve really liked this feature in previous releases because I could easily create template hierarchy based templates for sidebars (sidebar-front-page.php) or page headers (page-header-front-page.php).

I realized the sidebar_path() function is disappeared and you changed this to a simple get_template_part() function. Do you have a reason why did you drop this functionality?

I’ve then tried to reproduce the same functionality with the current wrapper. It was kind of tricky but now I have a working solution:

function sidebar_path() {
    return template_wrap(new Wrapper(template_unwrap(), 'partials/sidebar.php'), 'sidebar');
}

I’m not sure if this is a proper way of doing this so I’m asking if I missed something and there is a much easier way of doing it?

Thanks

1 Like

I rewrote some of the template stuff to bring this back and make it a bit easier to use.

Feel free to test it if you’d like.

If you’re sticking with the old code, I think you could use something like…

helpers.php

function get_sidebar()
{
    get_template_part('partials/sidebar', basename(template_unwrap(), '.php'));
}

base.php

<?php get_sidebar(); ?>

That’s untested, but I think it would work fine.

1 Like

Hi,

Thank you it’s much cleaner now. I’ve tested and works correctly.