Layout Manager / Dynamic Sidebars

Home Page – v1.1 Forums Extensions Layout Manager Layout Manager / Dynamic Sidebars

This topic contains 8 replies, has 2 voices, and was last updated by  Andy Wilkerson 4 years, 1 month ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #4874

    Mark Woodroof
    Participant

    Hi

    Sorry if these are numpty questions (?!) but I am still getting my head around the Runway framework…I have bought the dev version plus Vellum, Incentive and Bootstrap themes and have been playing with them all to understand it better.

    In particular, I want to implement dynamic sidebars based on some PHP conditions (eg using my LearnDash example again, if Course ID = xyz and user has access, then show sidebar X elseif Y elseif Z else…) which I would normally place in the sidebar.php template…

    1) How to implement Layout Manager on Bootstrap Theme
    I am slightly confused how best to implement Layout Manager in the Bootstrap Starter theme – do you have any tips / guidance on the main steps? Unless I am missing the point, there seems to be a bit of a ‘disconnect’ between using the WordPress template pages provided (for full width/right sidebar etc) and the layout manager. Any tips gratefully received.

    2) Dynamic Sidebars in Vellum theme
    How would you recommend adding some PHP conditions to make the sidebars dynamic (based on a similar if/elseif/elseif/else) in the Vellum theme?

    Many thanks in advance

    Mark

    #4878

    Andy Wilkerson
    Keymaster

    1) The main power of the Layout Manager is it’s ability to specify entirely unique design, header and footer data. Using it you can pull the values for your header, override them for a single page, swap out footers and even override default design settings for that layout. Applying that layout to a category, post type or single page makes it capable of having a very different appearance than the default design settings.

    Templates are just a structure inside WP that control the content area. You can specify settings, theme options, colors, headers, footers, etc. They are static and cannot change. Try not to think of the Layout Manager as a “template” tool. The content section of the layout manager is useful if you wanted to universally change a sidebar or content structure across many pages at once, but that’s a minor feature. Once you think of the Layout Manager as an extension of the theme options you will discover it’s true power. It’s very different from a template builder and that’s an easy thing to get confused.

    Vellum is probably the best example of the power of the Layout Manager. We’ve replicated most of the main theme options so they can be uniquely controlled on each layout. To make use of that you must code the conditions to tell the theme to use the settings in the layout to override those in the theme options. That’s the part where it’s under your control as to how to apply and implement the settings and choose overrides. It won’t simply override a theme option because it has the same name. You have to write that condition, but it’s not hard to test for the value in a layout and use it instead of your default in the theme options. This is what we do in Vellum and we do it a lot.

    2) If you’re looking to have a sidebar selected based on another setting (say a value in the Layout Manager) you could populate a select dynamically with the list of available sidebars and then a user could choose one. If the setting is based on some other criteria, such as a plugin setting that you’re deciding if they choose A use sidebar 1, B sidebar 2, etc. That’s going to be something where you’ll probably want to either code the sidebars directly in the theme or make sure they don’t get deleted in the Runway Sidebars extension. Users have the control to delete dynamic sidebars. If you’re coding a condition that expects one to exist (from a dynamically created sidebar) that assumes the user won’t delete it. If they do you’ll have a problem.

    If you need more details on any of that, just let me know. Thanks!

    #4879

    Mark Woodroof
    Participant

    Hi Andy

    Thanks for that. Clearly I have a lot to learn!

    This is the main reason I bought the Vellum, Incentive and Bootstrap themes – so I could see how you have developed the options screens / layouts etc!

    However, I am not sure this quite answers what I am trying to do though…

    I want to use either the Vellum or Bootstrap theme and use Layout Manager for the powerful features you mentioned (ie swapping out headers, footers, setting other options etc) on a per page basis. I get that this is an extension of the theme options and is very powerful (this is one of the reasons I like the Runway framework so much).

    However, what is currently stopping me from using either of these themes is that I want to make one of sidebars change based on the site user’s (LearnDash) course signups and completion data. But I just can’t see how to do it…

    In other words, for the (LearnDash course) custom type, to have a menu that dynamically changes for visitors who have either not enrolled, or if they have, show a different course sidebar specific to each course.

    Excuse my poor PHP skills but in my old theme, I have been doing this using code in my sidebar.php along the lines of:

    		if( is_page() ) { // General Pages
    $dynamic_sidebar = 'sidebar-page';	
    } 
    elseif( is_singular( 'sfwd-courses' ) ) { // Single Course
    // Get the vars for LearnDash course check 
    $user_id = get_current_user_id();
    $id = get_the_ID();
    $course_id = learndash_get_course_id($id);
    $course_title = get_the_title($course_id);
    $course_status = learndash_course_status($course_id, $user_id);
    //Now set the dynamic sidebar var
    if ( sfwd_lms_has_access($course_id) AND $course_id == "123" ) { 
    $dynamic_sidebar = 'sidebar-student-abc';
    } 
    elseif ( sfwd_lms_has_access($course_id) AND $course_id == "456" ) { 
    $dynamic_sidebar = 'sidebar-student-xyz';
    } 
    else {
    $dynamic_sidebar = 'sidebar-course-visitor';
    }
    } 		
    else { //else default sidebar
    $dynamic_sidebar = 'sidebar-page';
    }

    The problem is that I cannot see how I can apply this sort of PHP logic the sidebars on the Vellum (or bootstrap) theme…does that make sense?

    Thanks

    Mark

    #4880

    Andy Wilkerson
    Keymaster

    It could be the dynamic nature of Runway and the Layout Manager that’s causing the confusion. The code you’re showing should work in any Runway theme and can be put in the sidebar.php file also. If you do include it in that WP template file, you will need to make sure you call the get_sidebar() function inside your content templates.

    If you wanted to load that same function dynamically to any sidebar on any layout, it’s probably something you would want to write into a shortcode or widget. This would let you pull the function for displaying that output into the desired locations using the WP admin. That would maintain the fluid structure of swapping sidebars and layouts.

    https://codex.wordpress.org/Widgets_API#Developing_Widgets

    That’s probably how I would do it. I tend to avoid creating widgets for my themes because they can only be used in sidebars. When you make a shortcode it can be added into content or directly in a sidebar with a text widget. It’s up to you how you’d like to apply this. If you did go the shortcode route that would allow you to also include the content directly into specific pages, or using Vellum into a static content bloc to be added anywhere you have a layout, header, footer, etc. They’re two different ways you could accomplish the same thing. If you’re sure it’s only going to be in sidebars, a widget will work.

    #4887

    Mark Woodroof
    Participant

    Hi Andy

    Thanks for that – it seems obvious now you say it! Obviously, I could not see the wood for the trees…

    I am off to go and scratch my head and implement one of your solutions.

    Thanks again.

    Mark

    #4888

    Mark Woodroof
    Participant

    Hi Andy

    Just to let you know, I wrote a shortcode, put it in a content block which was called by the Layout Manager for the sidebar and it worked a treat!

    Very pleased I can now do the dynamic sidebars I need for this project!

    This also opens up a whole world of possibilities now that I get the relationship between creating functions/shortcodes, static content blocks and the layout manager.

    I think that the Runway framework with Layout Manager are absolutely brilliant!

    Thanks again for your brilliant and speedy / comprehensive support!

    Mark

    #4893

    Andy Wilkerson
    Keymaster

    It sounds obvious but it really isn’t. Making that mental jump to working in the Runway structure with so much being dynamic and not relying on static PHP templates is not easy. We always notice when a Vellum customer has that moment and all of a sudden a new world of possibilities reveals itself to them. They tend to react in a pretty excited way.

    I’m glad that worked. If you need any more help, I’m here!

    #4914

    Mark Woodroof
    Participant

    Thanks Andy

    I should have been quicker to spot it myself as I have used another theme (ProBusiness on Themeforest if you’re interested) that did something similar…but not as a proper theme framework, just a standalone theme…

    To anyone else reading this, it is really worth spending a few hours to understand Layout Manager as it opens up some very powerful options.

    I would also be interested in hearing from anyone else who has used Layout Manager in other interesting ways…

    #4920

    Andy Wilkerson
    Keymaster

    To anyone else reading this, it is really worth spending a few hours to understand Layout Manager as it opens up some very powerful options.

    Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

Fork us on Github.

Runway on Github

Learn with User Guides.

View the Guides


Thank you for being a part of Runway. We hope you have a great experience and together we can make Runway one of the best additions to the WordPress ecosystem and theme development. We're excited to have you here!

escort kutahya escort bornova escort beylikduzu escort amasya escort diyarbakir
Google+ ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?> ?>