ThemeShaper Forums » Thematic


Replace sidebar in single.php

(4 posts)
  • Started 10 years ago by mogito2000
  • Latest reply from helgatheviking
  • This topic is resolved
  1. mogito2000


    Im looking for a way to replace the sidebar in single.php with the post exerpt by specifying a category.

    ( ie. If i specify "category 1" then all post pages bar "category 1" will display the sidbar and "category 1" would display the current post exerpt )

    Im not sure if this is possible or if there is an easier way to go about doing this!

    Any help would be much appreciated.



    Posted 10 years ago #
  2. at first i thought you'd do best to switch off the sidebar, but then i realized you would also lose the hooks you will need over there to add your custom content. instead i think you should filter the widgets array to point the primary and secondary widgets to run off of your function instead of the thematic default... which pretty much says 'if i am active i will display'. by writing your own widget function you can 'if it is a single page do something else here... if not ..blah blah.

    here's how you point the widgets to your new functions

    /* Modify the Widget Areas */
    function mod_widget_areas($content) {
    	$content['Primary Aside']['function'] = 'child_primary_aside';
    	$content['Secondary Aside']['function'] = 'child_secondary_aside';
    	return $content;
    add_filter('thematic_widgetized_areas', 'mod_widget_areas');

    Here is how you'd define the new functions (not their names should match to what you put in the array above.

    // Define the Primary Aside
    function child_primary_aside() {
    	if (is_single()) {
    	   // do your thing with the excerpts
    	elseif (is_active_sidebar('primary-aside')) {
    		echo thematic_before_widget_area('primary-aside');
    		echo thematic_after_widget_area('primary-aside');
    // Define the secondary Aside
    function child_secondary_aside() {
    	if (is_single()) {
    	   // do your thing with the excerpts- leave blank- whatevever
    	elseif (is_active_sidebar('secondary-aside')) {
    		echo thematic_before_widget_area('secondary-aside');
    		echo thematic_after_widget_area('secondary-aside');

    that should get you started

    Posted 10 years ago #
  3. mogito2000

    Wow, that worked perfectly!

    Thanks for your help helgatheviking, once again....!


    Posted 10 years ago #
  4. cool. sometimes i just guess and offer what i like to think of as a nudge in the right direction, but i actually tested that one. don't forget to mark the thread as resolved.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.