ThemeShaper Forums » Thematic

[closed]

Sidebar Help - Want to add hardcoded aspects above primary sidebar

(5 posts)
  • Started 8 years ago by fanalejr
  • Latest reply from krowchuk
  • This topic is resolved
  1. Hey all,
    Been trying to figure out a way to handle this, couldn't find an exact answer on the forums so I'm hoping someone can help me out.

    I'm developing a child theme with a 3 column layout. Primary sidebar to the left, content, then secondary sidebar to the right. I have created a theme options panel, and one of the options I have is for the user to upload a photo of themselves, which SHOULD be added above the primary sidebar, and I wanted to also add options for adding a secondary menu below that image - outside of using a widget.

    The thematic_abovemainasides action doesn't work because of the necessary CSS for the layout.
    I tried str_replace with the thematic_before_widget_area action, but that could only take me so far

    I guess my question would be is there a way to completely rewrite the thematic_before_widget_area function without attacking thematic's core files?

    Something so I could do the following?

    // this function returns the opening CSS markup for the widget area
    function thematic_before_widget_area($hook) {
    $content = "\n";
    if ($hook == 'primary-aside') {
    $content .= '<div id="primary" class="aside main-aside">' . "\n";
    } elseif ($hook == 'secondary-aside') {
    $content .= '<div id="secondary" class="aside main-aside">' . "\n";
    } elseif ($hook == '1st-subsidiary-aside') {
    $content .= '<div id="first" class="aside sub-aside">' . "\n";
    } elseif ($hook == '2nd-subsidiary-aside') {
    $content .= '<div id="second" class="aside sub-aside">' . "\n";
    } elseif ($hook == '3rd-subsidiary-aside') {
    $content .= '<div id="third" class="aside sub-aside">' . "\n";
    } else {
    $content .= '<div id="' . $hook . '" class="aside">' ."\n";
    }
    $content .= "\t" . '<ul class="xoxo">' . "\n";
    return apply_filters('thematic_before_widget_area', $content);
    }

    And replace it with something like this?


    // this function returns the opening CSS markup for the widget area
    function thematic_before_widget_area($hook) {
    $content = "\n";
    if ($hook == 'primary-aside') {
    $content .= '<div id="primary" class="aside main-aside">' . // ADD MORE FUNCTIONALITY HERE "\n";
    } elseif ($hook == 'secondary-aside') {
    $content .= '<div id="secondary" class="aside main-aside">' . "\n";
    } elseif ($hook == '1st-subsidiary-aside') {
    $content .= '<div id="first" class="aside sub-aside">' . "\n";
    } elseif ($hook == '2nd-subsidiary-aside') {
    $content .= '<div id="second" class="aside sub-aside">' . "\n";
    } elseif ($hook == '3rd-subsidiary-aside') {
    $content .= '<div id="third" class="aside sub-aside">' . "\n";
    } else {
    $content .= '<div id="' . $hook . '" class="aside">' ."\n";
    }
    $content .= "\t" . '<ul class="xoxo">' . "\n";
    return apply_filters('thematic_before_widget_area', $content);
    }

    If someone knows of an easier/better way to accomplish what I'm after, let me know -
    Thanks!

    Posted 8 years ago #
  2. Hi!

    Although I don't quite understand what you are trying to accomplish (my php knowledge is minimal at best) I ran into a similar issue with the 3 column layout you are using and wanting to hard-code some php functions into the aside on the left above and below any widgets. I wanted to add a featured image thumbnail, a custom field caption for that image both above widgets and then some output by plugins that didn't have widgets, below the widgets in that aside.

    Adding your code to abovemainasides breaks the layout and I could never figure out how to fix it with css so that it looked like it was a part of the aside.

    Is this kind of along the line of what you would like to do?

    I accomplished this by opening a div in thematic_abovemainasides, putting my php in there, and then closing it in thematic_between. Of course then I had to style that div, so I gave it an ID of main-wrap similar to #main and also gave it the classes of aside and main-aside. It worked but wasn't elegant.

    I figured there might be a way to filter, but that is way beyond my scope!

    My thoughts were maybe you could filter out the opening div html of main aside and then filter it back in with your code?

    If you come up with a solution - let me know!

    Posted 8 years ago #
  3. Some ideas...

    Wrap a div around your main aside:

    // add a main aside wrapper div
    function open_wrapper {
    ?>
      <div id="main-wrap" class="aside main-aside">
    <?php // your php code here that will display above widgets
    }
    add_action('thematic_abovemainasides','open_wrapper');
    
    // close the main aside wrapper div
    function close_wrapper {
    ?>
      </div><!-- end main-wrap -->
    }
    add_action('thematic_betweenmainasides','close_wrapper');

    In your css you will want to copy your #main rules into #main-wrap and then perhaps over ride / change some of your #main rules, probably border: none; etc.

    Tested, works.

    So, without knowing much about filters, perhaps something similar could be done, where you strip out <div id="main" class="aside main-aside"> and the opening

      from widget_area_primary_aside()? and then reinsert it with <div id="main" class="aside main-aside"> and the opening
      and the php code?
    Posted 8 years ago #
  4. krowchuk -

    Great idea! I managed to make that work - I'm not sure if there is a better way to do it, but your way certainly worked for me! Thanks so much for the reply

    Posted 8 years ago #
  5. You are welcome, glad it worked out for you!
    Perhaps you might wish to mark this thread as resolved?

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.