-
AuthorPosts
-
February 15, 2021 at 5:45 pm #1280598
first – the old method to have the ALB from the opening a new post/page does not work anymore – even if i use .on(‘load’ …:
function trigger_alb_on_load(){ ?> <script> (function($){ $(window).on('load', function(){ $("#avia-builder-button").trigger('click'); }); })(jQuery); </script> <?php } add_action('admin_head-post-new.php', 'trigger_alb_on_load');
i do not hear that this old hook is deprecated too in jQuery 3.5.1
Now: is there a way to have a predefined set of layout elements on edit a new portfolio ?
i got that on older Enfold Versions in use to have from the beginning some standard settings f.e.:
function ava_enfold_builder_layout_mod(){ add_filter('avf_builder_elements', 'avf_enfold_builder_layout_settings_mod', array( 'portfolio' )); } add_action( 'after_setup_theme', 'ava_enfold_builder_layout_mod' ); function avf_enfold_builder_layout_settings_mod($elements){ $counter = 0; foreach($elements as $element){ // Layout > Sidebar Settings if($element['id'] == 'layout') { $elements[$counter]['std'] = 'sidebar_right'; } // Layout > Footer Settings if($element['id'] == 'footer') { $elements[$counter]['std'] = ''; } // Layout > Title Bar Settings if($element['id'] == 'header_title_bar') { $elements[$counter]['std'] = 'hidden_title_bar'; } // Layout > Header visibility and transparency if($element['id'] == 'header_transparency') { $elements[$counter]['std'] = ''; } $counter++; } return $elements; }
the thought if i include this to the function:
if($element['id'] == 'sidebar') { $elements[$counter]['std'] = 'custom_widget_area'; }
i can have a preset of the sidebar used on start.
The reason why it would be nice is that I want to make it as easy as possible for my client to create a new portfolio, with the values that I have set aside for it.
So for example a predefined category or a widget-area, which should be used by default.I found something form the other helpful user mensmaximus- but it does not do the job now
February 18, 2021 at 1:52 pm #1281990Hey Guenter,
Thank you for the inquiry.
It seems to be working properly on our end, still. Try to check if the current view has the portfolio post type.
function ava_enfold_builder_layout_mod(){ add_filter('avf_builder_elements', 'avf_enfold_builder_layout_settings_mod', 10001, 1); } add_action( 'after_setup_theme', 'ava_enfold_builder_layout_mod' ); function avf_enfold_builder_layout_settings_mod($elements){ if(avia_get_current_post_type() == "portfolio") { $counter = 0; foreach($elements as $element){ // Layout > Sidebar Settings if($element['id'] == 'layout') { $elements[$counter]['std'] = 'sidebar_right'; } // Layout > Footer Settings if($element['id'] == 'footer') { $elements[$counter]['std'] = ''; } // Layout > Title Bar Settings if($element['id'] == 'header_title_bar') { $elements[$counter]['std'] = 'hidden_title_bar'; } // Layout > Header visibility and transparency if($element['id'] == 'header_transparency') { $elements[$counter]['std'] = ''; } $counter++; } } return $elements; } function avia_get_current_post_type() { global $post, $typenow, $current_screen; if ($post && $post->post_type) return $post->post_type; elseif($typenow) return $typenow; elseif($current_screen && $current_screen->post_type) return $current_screen->post_type; elseif(isset($_REQUEST['post_type'])) return sanitize_key($_REQUEST['post_type']); return null; }
Check for post type based on: https://wp-mix.com/get-current-post-type-wordpress/
We can also use this: https://gist.github.com/DomenicF/3ebcf7d53ce3182854716c4d8f1ab2e2
Best regards,
IsmaelFebruary 20, 2021 at 1:27 am #1282348Neither the New Portfolio – opens with advanced layout editor at start – nor the custom-widget-area is set from the beginning as right sidebar.
Yes the right-sidebar was activated from the beginning – but the wanted widget-area not ( on opening new portfolio it is set to standard widget area)I can not imagine that it is due to Enfold 4.8.0-dev-6
- This reply was modified 3 years, 9 months ago by Guenni007.
February 23, 2021 at 12:08 pm #1283047Hi,
Thank you for the info.
You may need to adjust the actual sidebar option aside from the layout option above.
// Layout > Sidebar Settings if($element['id'] == 'sidebar') { $elements[$counter]['std'] = 'Custom Widget Area'; }
In the std parameter or key, define the actual name of the widget area.
It might be a good idea to change the title of the layout settings to “Layout Settings” to avoid confusion.
Best regards,
IsmaelFebruary 24, 2021 at 12:05 pm #1283363Thanks Ismael – but there is no difference on the code i posted here for the sidebar: https://kriesi.at/support/topic/preset-a-portfolio-to-have-on-default-a-custom-widget-area-shown/#post-1280598
that part : “the thought if i include this to the function…” – but it was more trivial then i thought.
Because the line$elements[$counter]['std'] = 'Portfolio';
is case-sensitive my custom-widget-area for those portfolio entries is called : Portfolio thats all :lol
but my first code to open a new portfolio with the well known snippet – first code here: https://kriesi.at/support/topic/preset-a-portfolio-to-have-on-default-a-custom-widget-area-shown/#post-1280598 does not work anymore
(jQuery 3.5.1 with no migrate helper)the rest is considered solved, since I didn’t think of treating it case-sensitive
February 26, 2021 at 2:52 pm #1283856Hi,
Is the block editor active in the installation where you are testing this? If yes, we might have to delay the execution of the script a bit to make sure that the ALB switch button already exists. Please try this script.
function trigger_alb_on_load(){ ?> <script> (function($){ $(document).ready(function(){ setTimeout(function() { var container = $('.edit-post-header__settings').first(); var btn = container.find('.avia-builder-button').first(); btn.trigger('click'); }, 500); }); })(jQuery); </script> <?php } add_action('admin_head-post-new.php', 'trigger_alb_on_load');
Best regards,
IsmaelFebruary 26, 2021 at 11:22 pm #1284018Thanks – that is a good idea to have a timeout function – with it the old snippet works too:
function trigger_alb_on_load(){ ?> <script> (function($){ $(window).on('load', function(){ setTimeout(function() { $("#avia-builder-button").trigger('click'); }, 500); }); })(jQuery); </script> <?php } add_action('admin_head-post-new.php', 'trigger_alb_on_load');
even 300ms is enough – maybe document ready will also suffice
March 1, 2021 at 1:49 pm #1284421What if i like to set a layout only for : search-results page !
and for archive tag pages ?March 2, 2021 at 5:17 pm #1284831Hi,
You might be able to use the avia_layout_filter to change the layout of the default templates. I’ve seen you use it before.
// https://kriesi.at/support/topic/tag-archive/#post-1053634
Or the avf_custom_sidebar filter to assign a different widget area to a certain template or page.
// https://kriesi.at/support/topic/custom-sidebar-on-buddypress-pages/#post-1229447
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.