ThemeShaper Forums » Thematic

[closed]

How To Rename Widget Area Classes

(5 posts)
  • Started 4 years ago by Devin
  • Latest reply from EricH
  • This topic is resolved
  1. I can't figure out how to filter this, since I need the $hook variable to make it work. Any ideas?

    This is the actual Thematic code:

    // 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);
    }

    I'd like it to display something different for index-top, like so (see near bottom, class="mydifferentclass":

    // 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";
            } elseif ($hook == 'index-top') {
    		$content .= '<div id="index-top" class="mydifferentclass">' . "\n";
    	} else {
    		$content .= '<div id="' . $hook . '" class="aside">' ."\n";
    	}
    	$content .= "\t" . '<ul class="xoxo">' . "\n";
    	return apply_filters('thematic_before_widget_area', $content);
    }
    Posted 4 years ago #
  2. Hi Devin,

    You don't really need $hook since you know exactly how $content will output. You just filter thematic_before_widget_area() using str_replace.

    function child_indextop_class($content) {
    	$child_class = str_replace('index-top" class="aside', 'index-top" class="mydifferentclass', $content);
    return $child_class;
    }
    add_filter('thematic_before_widget_area', 'child_indextop_class');

    Cheers,
    Gene

    Posted 4 years ago #
  3. Did the trick. Thanks Gene.

    Posted 4 years ago #
  4. yes! i just needed this. i couldn't figure the filter either, b/c the $hook variable was empty.

    Posted 3 years ago #
  5. Is there a way to replace the entire string? Ex: <div id="primary" class="aside main-aside"> to <aside id="primary" class="aside main-aside">

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.