ThemeShaper Forums » Thematic

[closed]

Remove right sidebar from all "pages"?

(20 posts)
  • Started 3 years ago by jhsizemore
  • Latest reply from jhsizemore
  • This topic is resolved
  1. I'm using the three column layout and I'd like to remove just the right sidebar from all pages (as opposed to the front page, blog posts, etc... Those should remain 3 column). It looks like it would be easy to copy and modify the thematic_sidebar function to do this by having it call on a modified version of the sidebar.php file (in the child theme) that just has the right bar commented out. I'm new to thematic and child theme modification (I'm a recent convert from gut hacking themes) so I feel like there is a little piece of the puzzle I'm missing and I hope someone can provide it.

    Or maybe I've got it all wrong and I need to be set in a different direction.

    Anyhow, thoughts would be appreciated.

    Posted 3 years ago #
  2. does this help?
    http://forums.themeshaper.com/topic/alternating-sidebars-depending-on-homepages

    you'll have to adjust the conditional logic

    this is also relevant:
    http://forums.themeshaper.com/topic/something-new-bout-widgetized-areas/page/2

    Posted 3 years ago #
  3. All this goes in my functions.php, correct?:

    function change_widgetized_area($content) {

    $content['Primary Aside']['args']['function']='child_1st_subsidiary_aside';
    $content['Secondary Aside']['args']['function']='child_2nd_subsidiary_aside';

    return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area');

    function child_1st_subsidiary_aside {
    if (is_active_sidebar('primary-aside') AND is_home() ) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }

    function child_2nd_subsidiary_aside [
    if (is_active_sidebar('secondary-aside') AND !(is_home() ) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }

    Posted 3 years ago #
  4. This code has given me several critical errors, and I've been able to handle some of them but I'm currently a little stuck.

    Here is what I have now:

    function change_widgetized_area($content) {

    $content['Primary Aside']['args']['function']='child_1st_subsidiary_aside';
    $content['Secondary Aside']['args']['function']='child_2nd_subsidiary_aside';

    return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area');

    function child_1st_subsidiary_aside() {
    if (is_active_sidebar('primary-aside') AND is_home() ) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }

    function child_2nd_subsidiary_aside() {
    if (is_active_sidebar('secondary-aside') AND !(is_home() ) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }

    I'm currently getting an error on this line:
    if (is_active_sidebar('secondary-aside') AND !(is_home() ) {

    Posted 3 years ago #
  5. you are missing a closing parens }

    if (is_active_sidebar('secondary-aside') AND !(is_home() )) {

    1. for the forum- put your code between to backtick characters. if you have a US keyboard it is usually in the top left.

    2. get yourself a decent text-editor. something like Notepad++ which has syntax highlighting and when you select a parens it will highlight it and match it w/ its partner.

    http://download.cnet.com/Notepad/3000-2352_4-10327521.html

    Posted 3 years ago #
  6. He doesn't really need it though.

    Change the line to:

    if ( is_active_sidebar('secondary-aside') AND !is_home() ) {

    I've removed the opening bracket between the NOT (!) symbol and is_home().

    Posted 3 years ago #
  7. Helga, when I first read through the second link you provided above, I couldn't figure out what you were referencing. Then I went through and read each post, realizing that the thread was derailed halfway through to something very relevant to my question.

    The feeling I came away with is that my question is a common one for someone of my skill level who is developing a Thematic child theme, but that, while you have offered some theoretical suggestions, no one has come up with a solid answer to the question.

    Would it be kosher to offer to pay for a solid answer that would be released to the community? If so, do you know who in the Thematic community commonly freelances in this way? It seems like something that could be parsed out in 25-30 minutes for someone who really knows what their doing. I'm willing to pay $25-30 via Paypal for a solid answer to my specific question with an eye toward making that answer accessible to others who want X sidebar on Y page only.

    Posted 3 years ago #
  8. yes it is a very common question, i've answered this question personally more than once. the search here isn't the best, but that post IS the solution. i've used it myself to switch off the secondary aside in certain places.

    3 columns http://www.peterwade.com/
    2 columns http://www.peterwade.com/blog

    it is a matter of picking the right conditional logic.

    clarify exactly where you want each sidebar to appear (and not appear) and i'll sort it out. and if you want you can contribute $30 to my wine fund then i will not say no.

    Posted 3 years ago #
  9. (l) - left sidebar
    (m) - main content
    (r) - right sidebar

    I am using this three column layout:
    (l)(m)(r)

    I would like it to be (l)(m)(r) on the home page, blog posts, archives and anywhere else as a default.

    On pages, those created by page.php, I want the layout to be (l)(m), where I will use CSS to expand the main content area to replace the removed right sidebar.

    If you have the time and inclination, an explanation of how one picks the right conditional logic in this situation may be of benefit to those who are bound to ask this question in the future.

    I will gladly contribute to your wine fund. Just let me know where I might do so.

    Posted 3 years ago #
  10. ok- since the left sidebar (which i am presuming is the Primary Aside) is always on, we don't need to monkey with that. we then point the secondary aside to its new function. upon closer inspection i realized that you had an extra ['args'] in your attempt. that is not where the 'function' parameter lives (it lives at $content['Secondary Aside']['function'] ) , so your function was never being called. sharper eyes in the morning i guess. this actually means you never even GOT to the point of testing your conditional logic, b/c your function was never being swapped into place.

    next we need to select some conditional logic. this is about as much info as you'll ever need on conditional logic:
    http://codex.wordpress.org/Conditional_Tags

    i know i've read some complaints on here before about the codex being confusing, but still that is where the information is.

    you also might need a little primer on PHP logic if you aren't familar:
    http://php.net/manual/en/language.operators.logical.php

    now to "translate" those 2 posts into "show the secondary aside on anything that isn't a page"

    the function that displays the aside by default has this bit of conditional logic:
    if (is_active_sidebar('secondary-aside'))

    which only tests if there is a widget in the defined widget area. well we want to run more tests... so we need to tack on an AND or the other way to write it && (i dont honestly know the difference between AND and && and they both probably work)

    you don't want it on any "page". so that says... ok let's test for a page with wordpress's is_page() logic, and let's use the NOT ! modifier to make it negative

    if (is_active_sidebar('secondary-aside') && !is_page() )

    if your front page is your blog... which would satisfy is_home() then you are done and the above would work just fine. if your front page is an actual page and you'd like to still show the secondary aside then you must get a little trickier.

    if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() ) )

    what has happened here? the vertical pipes mean OR. same as w/ the AND versus && i don't really know if there is much difference. if you are less familiar w/ php, OR is probably more readable. anyway, with parens i've grouped (is_front_page() || !is_page() ) so that if one of those is true, AND the sidebar is active, the secondary aside will display. is_front_page() is how you test for the page that has been set to be the static home page.

    since i don't know whether your home page is static or a blog i gave both options.

    i've left it with the assumption that you have a static home page, but you can scale it back if you aren't.

    the full function:

    //Point Secondary Aside to new function
    function change_widgetized_area($content) {
    	$content['Secondary Aside']['function']='child_2nd_subsidiary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area');
    
    //adjust where secondary aside displays
    function child_2nd_subsidiary_aside() {
    	if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() ) ) { //adjust logic on this line
    		echo thematic_before_widget_area('secondary-aside');
    		dynamic_sidebar('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');
    	}
    }

    my wine fund lives at helgatheviking [at] gmail [dot] com . i'm partial to sweet whites, though a nice malbec goes well with chocolate.

    let me know if you have any trouble, but i tested this locally and it works w/ thematic 0.9.8

    Posted 3 years ago #
  11. Read your response, dropped in the code and it works like a charm.

    Please enjoy your wine.

    Thanks,
    jhsizemore

    --

    For those in the future who may try to use this piece of code to accomplish something similar,

    Keep in mind that I was only trying to remove one sidebar. If you reference the other thread where helga posted similar code which addressed a problem dealing with two sidebars (http://forums.themeshaper.com/topic/alternating-sidebars-depending-on-homepages), then it seems like you will be able to cobble the two together, along with conditional tags which helga has discussed above, to accomplish what you need.

    Posted 3 years ago #
  12. you're welcome. will do! don't forget to mark as resolved.

    Posted 3 years ago #
  13. Hey helga,

    My client has also requested that this feature be available on posts. I have played with the is_single conditional tag a bit, but I keep causing critical errors and I'm really sure how the syntax should work so that I can also define posts as having only two columns? Is there a simple fix for this?

    Thanks

    Posted 3 years ago #
  14. is there anywhere that you DO want the secondary-aside to display?

    but i would have guessed

    if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() ) ) {

    should become

    if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() || !is_single() ) ) {

    Posted 3 years ago #
  15. I tried that method, maybe I just got something wrong in the syntax. To clarify, we're only going to add a few of the many blog posts to this declaration. So some of them will have two columns but many of them will have three.

    I'll give this a shot.

    Thanks helga

    Posted 3 years ago #
  16. so you need to toggle whether the sidebar displays on a per post basis? i did that one time w/ a metabox, so you could set a custom field or a metabox and capture some meta data and then test for that meta value in your conditional

    Posted 3 years ago #
  17. Yes, that is what I need to do. Cool tip.

    Does the conditional need additional logic to search for the meta value or should I just be able to plug that into !is_single('VALUE')? The WP codex page makes it seem as though these conditionals will except a wide variety of variable without further qualification, hopefully it is so in this case.

    Posted 3 years ago #
  18. you'll definitely need extra info.. b/c you'll need to get the metabox value and test against IT. you could do a fullblown meta box ( i use WP Alchemy on almost every project) but it might be overkill for a radio input. devin also put together a nice tutorial on basic metaboxes (its for custom post types but you can easily extract it to posts. or you could just use a custom field if you don't care for a GUI.

    you'll also need to global $post in your child_2nd_subsidiary_aside function i think.

    so assuming you are saving a meta value of 'hide' for the meta key 'kia_sidebar'. something like:

    //adjust where secondary aside displays
    function child_2nd_subsidiary_aside() {
    global $post;
    
    $meta_value = get_post_meta($post->id, 'kia_sidebar');
    
    	if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() || $meta_value!='hide' ) ) { //adjust logic on this line
    		echo thematic_before_widget_area('secondary-aside');
    		dynamic_sidebar('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');
    	}
    }

    is_single('100') tests to see if you are on a post w/ the ID of 100. it has nothing to do w/ meta.

    Posted 3 years ago #
  19. I tried devin's code and couldn't get it to work, kept getting a critical error on the first non-comment line of code. I assume it works, as others seem to be happy with it in the comments. Not sure what's going on.

    I then switched to just using the custom field box. I have the name and meta as you have defined them and the code doesn't break the site, but it's not functioning.

    With my raggedy PHP skills this is what I have right now:

    /Point Secondary Aside to new function
    function change_widgetized_area($content) {
    	$content['Secondary Aside']['function']='child_2nd_subsidiary_aside';
    	$content['Secondary Aside']['function']='child_2nd_subsidiary_aside_single';
    return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area');
    
    //adjust where secondary aside displays
    function child_2nd_subsidiary_aside() {
    	if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page(array ('parties', 'holidays', 'recipes', 'crafts', 'printables', 'educational', 'sitemap', 'holidays', '1756')) || !is_single('twocolumn') ) )  { //adjust logic on this line
    		echo thematic_before_widget_area('secondary-aside');
    		dynamic_sidebar('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');
    	}
    }
    
    //adjust where secondary aside displays
    function child_2nd_subsidiary_aside_single() {
    global $post;
    
    $meta_value = get_post_meta($post->id, 'kia_sidebar');
    
    	if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() || $meta_value!='hide' ) ) { //adjust logic on this line
    		echo thematic_before_widget_area('secondary-aside');
    		dynamic_sidebar('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');
    	}
    }

    It seems to me that the lines of PHP you provided are not meant stand on there own and if I knew the slightest about what I was doing, I'd know exactly how to make them talk to the existing code. This is my sorry attempt at that. Am I even on the right path?

    Posted 3 years ago #
  20. Okay, so I realized my above code was actually breaking the previous functionality, so clearly it wasn't working. I've tried coming at it from a different angle, using the previous function as a template and renaming the new function so that it wasn't a duplicate.

    Here is the code for the new attempt:

    //Point Secondary Aside to new function
    function change_widgetized_area_post($content) {
    	$content['Secondary Aside']['function']='child_2nd_subsidiary_aside_post';
    return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area_post');
    
    //adjust where secondary aside displays
    function child_2nd_subsidiary_aside_post() {
    	global $post;
    
    $meta_value = get_post_meta($post->id, 'kia_sidebar');
    
    	if (is_active_sidebar('secondary-aside') && (is_front_page() || !is_page() || $meta_value!='hide' ) ) { //adjust logic on this line
    		echo thematic_before_widget_area('secondary-aside');
    		dynamic_sidebar('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');
    }

    So, I believe I should be able to start tinkering with the actual logic and feel relatively sure that that everything is hooked up correctly, if not as elegantly as it probably could be. Again, any direction is greatly appreciated and thanks for everything you've helped me out with so far.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.