ThemeShaper Forums » Thematic

[closed]

Widgets output two times

(10 posts)
  • Started 2 years ago by sheky
  • Latest reply from sheky
  • This topic is not resolved
  1. sheky
    Member

    Hi,

    I want to add specific widget areas on custom category pages to override thematic_blogdescription().

    Here is what I have done:
    1. registerd new sidebars in childtheme library/widget-areas.php

    function lul_home_tagline() {
    register_sidebar(array(
    'admin_menu_order' => 210,
    'name' => 'lul-home-tagline',
    'id' => 'lul-home-tagline',
    'description' => __('some text', 'thematic'),
    'before_widget' => thematic_before_widget(),
    'after_widget' => thematic_after_widget(),
    'before_title' => thematic_before_title(),
    'after_title' => thematic_after_title(),
    'priority' => 1,)
    );
    }

    add_action('init', 'lul_home_tagline');

    function lul_magazin_tagline() {
    register_sidebar(array(
    'admin_menu_order' => 220,
    'name' => 'lul-magazin-tagline',
    'id' => 'lul-magazin-tagline',
    'description' => __('some text.', 'thematic'),
    'before_widget' => thematic_before_widget(),
    'after_widget' => thematic_after_widget(),
    'before_title' => thematic_before_title(),
    'after_title' => thematic_after_title(),
    'priority' => 2,)
    );
    }

    add_action('init', 'lul_magazin_tagline');

    function lul_ekologija_tagline() {
    register_sidebar(array(
    'admin_menu_order' => 230,
    'name' => 'lul-ekologija-tagline',
    'id' => 'lul-ekologija-tagline',
    'description' => __('Prostor u koji se unosi tekst, slike, kod za prostor pored logoa na stranama kategorije ekologija.', 'thematic'),
    'before_widget' => thematic_before_widget(),
    'after_widget' => thematic_after_widget(),
    'before_title' => thematic_before_title(),
    'after_title' => thematic_after_title(),
    'priority' => 3,)
    );
    }

    add_action('init', 'lul_ekologija_tagline');

    2. Added childtheme_override_blogdescription() in my childetheme functions.php


    function childtheme_override_blogdescription() {

    if (is_category('ekologija')) {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-ekologija-tagline') . dynamic_sidebar('lul-ekologija-tagline') . thematic_after_widget_area('lul-ekologija-tagline') . "</div>";
    }
    elseif (is_category('magazin')) {
    echo "<div id=\"blog-description\">". dynamic_sidebar('lul-magazin-tagline') . "</div>";
    }
    elseif (is_category('aktivart')) {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-aktivart-tagline') . dynamic_sidebar('lul-aktivart-tagline') . thematic_after_widget_area('lul-aktivart-tagline') . "</div>";
    } else {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-home-tagline') . dynamic_sidebar('lul-home-tagline') . thematic_after_widget_area('lul-home-tagline') . "</div>";
    }
    }

    add_action('thematic_header','childtheme_override_blogdescription',4);

    3. For some reason widget area outputs widget twice, with weird mark-up like so:


    <li id="text-2" class="widgetcontainer widget_text">
    <div class="textwidget">text widget text</div>
    // this was the first one

    <div id="blog-description">
    <div id="lul-home-tagline" class="aside">
    <ul class="xoxo">
    1
    // this was the second one, and this is the markup I created in override function but it only pulls this weird '1'
    </div><!-- #lul-home-tagline .aside -->

    I was adding block of code by block of code in my override function to try to track when the duplication occurres and it happens when I call dynamic_sidebar('lul-ekologija-tagline').

    I was poking around this all day, I don't have any plugins instaled, so if anyone has idea what coulde have gone wrong, I would apreciate it if you could help me out.

    Many thanks in advance!

    Sheky

    Posted 2 years ago #
  2. why do you need a widget to replace the blog description? why not just write it into the childtheme_override function you have obviously already figured out?

    also unless you have specifically included childtheme library/widget-areas.php through an include or require in your child's functions.php i'm not 100% sure this file would get included automatically. i don't know that template hierarchy extends to sub-folders and am inclined to think it is only for specific WP templates, plus functions.php and style.css

    sidenote- please put code between backtick marks. makes it a lot easier to see what is code and what is narrative

    Posted 2 years ago #
  3. sheky
    Member

    Yes I have included it in child functions.php with include('library/widget-areas.php'); and widgets are registered, I see them in the admin panel. I have to use widgets as other people who will adminstrate the site are not tech-savy, and that content will be frequently changed and updated. But, yes, hardcoding it is my plan B.

    I am just very curious about this as this is first time I am using Thematic, and besides this glitch I am very much inclined in using it in the future.

    Posted 2 years ago #
  4. ok, just had to ask some basics. still don't think widgets it the best way. why not a theme option?

    BUT, as i was getting ready to test this on my own install i looked more closely at your code

    function childtheme_override_blogdescription() {
    
    if (is_category('ekologija')) {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-ekologija-tagline') . dynamic_sidebar('lul-ekologija-tagline') . thematic_after_widget_area('lul-ekologija-tagline') . "</div>";
    }
    elseif (is_category('magazin')) {
    echo "<div id=\"blog-description\">". dynamic_sidebar('lul-magazin-tagline') . "</div>";
    }
    elseif (is_category('aktivart')) {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-aktivart-tagline') . dynamic_sidebar('lul-aktivart-tagline') . thematic_after_widget_area('lul-aktivart-tagline') . "</div>";
    } else {
    echo "<div id=\"blog-description\">" . thematic_before_widget_area('lul-home-tagline') . dynamic_sidebar('lul-home-tagline') . thematic_after_widget_area('lul-home-tagline') . "</div>";
    }
    }
    
    add_action('thematic_header','childtheme_override_blogdescription',4); //the culprit. this line is unnecessary when using an override

    when you declare childtheme_override anything it is automatically added to the appropriate hook via thematic's core. you don't have to add it yourself w/ an add_action(). hence you are adding it a second time. remove the add_action line and it should work just fine... though i'd still advise another route.

    Posted 2 years ago #
  5. sheky
    Member

    Hmm, when I remove it, doesn't output anything.

    I see that the problem is with processing the dynamic_sidebar() in the override function I just can't figure out what it is. When I pass dummy text in override function it works as it should, when I put same dynamic_sidebar() anywhere else it works as it should.

    Any idea what could it be?

    I thought this will be faster than working with theme options, but it took too much of my time... :/

    Posted 2 years ago #
  6. sheky
    Member

    Actually, problem is passing any function trough override, I just tried with get_bloginfo('description'), instead of one I got two descriptions, but only one of them was inside a div I specified in override function.

    Here is the override:

    function child_override_blogdescription() {
    echo "<div id=\"blog-description\" class=\"prefix_1 grid_12 sufix_1 omega\">" . get_bloginfo('description') . "</div>";
    
    }
    add_action('thematic_header', 'child_override_blogdescription',4);

    And here is how it is rendered:

    <div id="blog-description" class="prefix_1 grid_12 sufix_1 omega">
    Just another WordPress site
    </div>
    <div id="blog-description">
    Just another WordPress site
    </div>

    Again, any idea what I am doing wrong? I ve omitted add_action('thematic_header', 'child_override_blogdescription',4); like you suggested but then override is not picked up...

    Posted 2 years ago #
  7. if you need the add_action for childtheme_override to appear then you aren't using the latest version:

    http://developing.thematic4you.com/thematic-development-release/

    there were some bugs specifically related to this that were fixed.

    i thought for a second that dynamic_sidebar() was echoing something when the override was meant to return something, but that isn't the case. update for sure, and then let me know where you are

    Posted 2 years ago #
  8. sheky
    Member

    Works like a charm! Thank you sooooooo much!

    Posted 2 years ago #
  9. sheky
    Member

    Actually, it is not working with dynamic_sidebar() :/
    Everything is fine when I use get_bloginfo()... that is why I thought this was resolved with the update, now I ucommented the dynamic_sidebar() piece of code and again same issue... so it could be a bug, or I overlooked something...

    I think I ll add all this through theme options later.

    Thanks again!

    Posted 2 years ago #
  10. sheky
    Member

    Definetly there is something wrong with the dynamic_sidebar(), not working on the override in the footer as well...

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.