-
AuthorPosts
-
October 10, 2015 at 3:11 pm #516810
Hi all,
I’d like to use two distinctively different layouts for a new site I’m building, one with top navigation and the other with sidebar navigation. But it seems I cannot have both at the same time, selecting one of them on a per page base…
I’d like to know if it’s possible to overwrite theme settings from within the page. For example, this is true for sidebar selection, in the Layout panel, so I guess it can be done for the header position also. So, my question: is there an easy way (in php) to set ‘header_position‘, “value”=>”header_left” on a particular page?
Thank you for your time, I know this is probably not the average question for support…
Mike
October 15, 2015 at 12:11 am #518990Hey Mike!
Add this to your child theme functions.php:
add_filter('avf_builder_elements', 'register_meta_elements', 10, 1); function register_meta_elements($avf_builder_elements) { $avf_builder_elements[] = array( "slug" => "layout", "name" => __("Header Position",'avia_framework'), "id" => "header_position", "desc" => "Select the position of the header", "type" => "select", "std" => "", "class" => "avia-style", "subtype" => array( __("Default",'avia_framework') => '', __('Top Header','avia_framework') =>'header_top', __('Sidebar Header (Left)','avia_framework') =>'header_left header_sidebar', __('Sidebar Header (Right)','avia_framework') =>'header_right header_sidebar', ) ); return $avf_builder_elements; } if(!function_exists('avia_header_setting')) { function avia_header_setting($single_val = false) { global $avia_config; if(isset($avia_config['header_settings']) && $single_val && isset($avia_config['header_settings'][$single_val])) return $avia_config['header_settings'][$single_val]; if(isset($avia_config['header_settings']) && !$single_val) return $avia_config['header_settings']; //return cached header setting if available $defaults = array( 'header_position' => 'header_top', 'header_layout'=>'logo_left menu_right', 'header_size'=>'slim', 'header_custom_size'=>'', 'header_sticky'=>'header_sticky', 'header_shrinking'=>'header_shrinking', 'header_title_bar'=>'', 'header_social'=>'', 'header_unstick_top' =>'', 'header_secondary_menu'=>'', 'header_stretch'=>'', 'header_custom_size'=>'', 'header_phone_active'=>'', 'header_replacement_logo'=>'', 'header_replacement_menu'=>'', 'header_mobile_behavior' => '', 'header_searchicon' => true, 'header_mobile_activation' => 'mobile_menu_phone', 'phone'=>'', 'sidebarmenu_sticky' => 'conditional_sticky', 'layout_align_content' => 'content_align_center', 'sidebarmenu_widgets' => '', 'sidebarmenu_social' => 'disabled', 'header_menu_border' => '', 'header_style' => '' ); $settings = avia_get_option(); //overwrite with custom fields if they are set $post_id = avia_get_the_id(); if($post_id && is_singular()) { $custom_fields = get_post_custom($post_id); foreach($defaults as $key =>$default) { if(!empty($custom_fields[$key]) && !empty($custom_fields[$key][0]) ) { $settings[$key] = $custom_fields[$key][0]; } } //check if header transparency is set to true $transparency = post_password_required() ? false : get_post_meta($post_id, 'header_transparency', true); if(get_post_meta($post_id, 'header_position', true)){ $header['header_position'] = get_post_meta($post_id, 'header_position', true); } } $header = shortcode_atts($defaults, $settings); $header['header_scroll_offset'] = avia_get_header_scroll_offset($header); if($header['header_position'] != "header_top") return avia_header_setting_sidebar($header, $single_val); //set header transparency $header['header_transparency'] = ""; if(!empty($transparency)) $header['header_transparency'] = 'header_transparency'; if(!empty($transparency) && strpos($transparency, 'glass')) $header['header_transparency'] .= ' header_glassy'; if(!empty($transparency) && strpos($transparency, 'hidden')) $header['disabled'] = true; if(!empty($transparency) && strpos($transparency, 'scrolldown')) { $header['header_transparency'] .= ' header_scrolldown'; $header['header_sticky'] = 'header_sticky'; } //deactivate title bar if header is transparent if(!empty($transparency)) $header['header_title_bar'] = 'hidden_title_bar'; //sticky and shrinking are tied together if($header['header_sticky'] == 'disabled') { $header['header_shrinking'] = 'disabled'; $header['header_scroll_offset'] = 0; } //if the custom height is less than 70 shrinking doesnt really work if($header['header_size'] == 'custom' && (int) $header['header_custom_size'] < 65) $header['header_shrinking'] = 'disabled'; //create a header class so we can style properly $header_class_var = array( 'header_position', 'header_layout', 'header_size', 'header_sticky', 'header_shrinking', 'header_stretch', 'header_mobile_activation', 'header_transparency', 'header_searchicon', 'header_unstick_top', 'header_menu_border', 'header_style' ); $header['header_class'] = ""; foreach($header_class_var as $class_name) { if(!empty($header[$class_name])) { if($header[$class_name] == "disabled") $header[$class_name] = $class_name."_disabled"; $header['header_class'] .= " av_".str_replace(' ',' av_',$header[$class_name]); } } //set manual flag if we should display the top bar $header['header_topbar'] = false; if(strpos($header['header_social'], 'extra_header_active') !== false || strpos($header['header_secondary_menu'], 'extra_header_active') !== false || !empty($header['header_phone_active'])){ $header['header_topbar'] = 'header_topbar_active'; } //set manual flag if the menu is at the bottom $header['bottom_menu'] = false; if(strpos($header['header_layout'],'bottom_nav_header') !== false) { $header['bottom_menu'] = 'header_bottom_menu_active'; } else { $header['header_class'] .= " av_bottom_nav_disabled "; } //header class that tells us to use the alternate logo if(!empty($header['header_replacement_logo'])) { $header['header_class'] .= " av_alternate_logo_active"; if(is_numeric($header['header_replacement_logo'])) { $header['header_replacement_logo'] = wp_get_attachment_image_src($header['header_replacement_logo'], 'full'); $header['header_replacement_logo'] = $header['header_replacement_logo'][0]; } } //header class that tells us to use the alternate logo if(empty($header['header_menu_border'])) { $header['header_class'] .= " av_header_border_disabled"; } $header = apply_filters('avf_header_setting_filter', $header); //make settings available globaly $avia_config['header_settings'] = $header; if(!empty($single_val) && isset($header[$single_val])) return $header[$single_val]; return $header; } }
That will add a new option in each Page where you can set the Header Position per Page.
Few things:
– There’s an issue with the search icon and sidebar headers so i’d suggest not activating it.
– Have the Top Header setting as default (in Theme Options), that way the header transparency settings (in each Page) will be available.Best regards,
JosueOctober 15, 2015 at 7:58 am #519060Hi Josue, thanks in advance for the code as well as the tips :)
I will give it a try and report back my feedback for other users’ future reference.
Thanks again
M.
October 15, 2015 at 8:21 am #519064Worked right off the bat !
Steps:
- Go to Theme Options and set the Logo and Main Menu to Left Sidebar
- If you wish, check the Display social icons below main menu
- Optionally, select a Main Menu Sidebar that will appear below main menu
- Now that everything is set… Re-Select the Top Header – as Josue Proposed – as the default Header
The settings for the Left Sidebar are saved – and become active if needed – even though the Top Header is set as default in the Theme Options.
This way, when you set the Header Position to Sidebar Header (Left) from within the page Layout settings, your Theme Options for Left Sidebar are applied.
Thanks again Josue,
I hope Kriesi incorporates this option in the next version of EnfoldM.
- This reply was modified 9 years, 2 months ago by Mike.
October 15, 2015 at 11:01 am #519112You are welcome, thanks for sharing your tips too :)
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.