bassjobsen / jbst

Powerful theme framework that can be used as a standalone website builder or as a framework to create child themes for wordpress build on Twitter's Bootstrap 3. Full customizable with LESS
http://www.jbst.eu/
GNU General Public License v2.0
96 stars 36 forks source link

Page template, left / right sidebar won't work #110

Closed bassjobsen closed 10 years ago

bassjobsen commented 10 years ago

question from @mjteves1986: I install this plugin on my childthemes: (http://wordpress.org/plugins/options-framework/) and set the sidebar into left-sidebar. The page is working. I was wondering why the single page is not working. always right-sidebar set. But the right sidebar is blank. If I uninstall it and use the method <?php if(is_single()) { global $jbst_layout; $jbst_layout == 'left-sidebar'; } ?> is still not functioning on single page. I attached the code on content.php, content-archive.php.

bassjobsen commented 10 years ago

Hi Mark,

Thanks for posting your issue. I test your situation and found some buggy code. Fixes are in the latest update, hope this helps.

First i found change the layout, using the metabox on a page won't work (is not saved). For an single post it seems to work find. It seems post_save is not called when only changing the metabox, alse described here http://wordpress.org/support/topic/save_post-not-working-getting-called. But that issue is over two years old?? I also found http://wordpress.org/support/topic/save_post-not-working, so maybe it is a new issue for 3.8.1 again?? I update the https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress but this dis make no sense. To fix i add an extra action hook to library/metaboxes/init.php:

        add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
        add_action( 'pre_post_update', array( $this, 'save_post' ), 10, 2 );

and a minor change in the save_post function:

    $post_type = $post ? (isset($post->post_type) ? $post->post_type : get_post_type( $post_id )): get_post_type( $post_id );

needed cause the pre_post_update hook did not send a post object.

Secondly i found the metabox set its default value to default, i changed this to false.

Now metabox setting should work again. Remember this setting per page or post overrule the global setting per type via the theme options plugin.

You also tried: <?php if(is_single()) { global $jbst_layout; $jbst_layout == 'left-sidebar'; } ?> this seems to work, when called right and on the right place. Not see the double == in your code. And also is_single() doesn't match a page, see http://codex.wordpress.org/Function_Reference/is_single try is_sigular or is_page in this case.

If you call this code too early is_sigular returns always false (cause the query didn't run yet) and if you call it too late the layout has been set already. Call it in content.php, content-archive.php will be too late. Also see: https://github.com/bassjobsen/jamedo-bootstrap-start-theme/issues/104

Call it in the beginning your templates like page.php (a copy of index.php of the parent), or add it to function.php:

function tsa() {
if(is_singular()) {  global $jbst_layout; $jbst_layout = 'three-column'; }
}
add_action( 'jbst_before','tsa' );