• dwzemens

    (@dwzemens)


    I have made several themes in WP, and no my way around the program pretty well. I have not worked with widgets, however. How much work is involved in making a theme “widget ready”?

    Thanks,

    – dz

Viewing 15 replies - 1 through 15 (of 42 total)
  • rudolf45

    (@rudolf45)

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    It’s easy. 10 lines of code, max.

    Your functions.php file needs to get a couple lines in it to create the sidebars. Your sidebars then need a slight modification to allow them to be replaced by widgets. No big deal at all. Takes less than 5 minutes, even for the most complex themes.

    Thread Starter dwzemens

    (@dwzemens)

    I am a bit confused. I downloaded and installed the plugin, added a functions.php file with this code only:
    <?php
    if ( function_exists(‘register_sidebar’) )
    register_sidebar();
    ?>

    I then added this code to my sidebar:
    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘Right’) ) : else : ?>

    buncha code/sidebar stuff here

    <?php endif; ?>

    I see the widget in the Admin panel, and drag and drop widgets onto the “widget bar”, but nothing happens on my sidebar display?

    What am I missing?

    Thanks,

    -dz

    rudolf45

    (@rudolf45)

    1. After dragging the widgets – do you click on the “Save Changes”? (I didn’t the first time and nothing happened… 🙂
    2. Is your sidebar correctly coded for the widgets? See the link I gave above, where they say the whole sidebar whould be a huge nested lists thing.

    Thread Starter dwzemens

    (@dwzemens)

    Yes to the “Save” and Yes to the nested lists and H2’s.

    I suspect my functions.php might need something else?

    Alex Cragg

    (@epicalex)

    i don’t think this is it, but try changing your if statement to

    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar('Right') ) : ?>

    or
    <?php if (function_exists('dynamic_sidebar')) {dynamic_sidebar('Right'); } ?>

    you dont need the end if with the second

    Alex Cragg

    (@epicalex)

    and just as a personal rant….i dont like sidebar widgets as most the time they don’t validate, or you get stupid header tags where you dont want them.

    If you design themes, you’ll know how to create php calls, which pretty much is what widgets do, but in an easy quickly changeable way…

    i suppose the advantage is that for and end user, it adds endless functionality…

    😀

    Thread Starter dwzemens

    (@dwzemens)

    epicalex,

    Thanks, your second suggestion works. I got it working. I see that I have to do a bit of CSS work to style the list items, eh?

    Alex Cragg

    (@epicalex)

    you sure do!!!!if you want it to validate, you’ll more than likely have to plunge into the widgets plugin itself and edit it as well.

    glad it worked

    😀

    Thread Starter dwzemens

    (@dwzemens)

    Thanks rudloph and Otto, too!

    jonimueller

    (@jonimueller)

    Well, I’ll add my two cents here. We have designed over two dozen themes for the WP Theme Viewer site and I mostly did a conditional statement to where if the plugin existed, the sidebar code for it would load; otherwise, it would be ignored. Can I keep that and still “widgetize” the sidebar? Or does what I’ve done with the conditional coding make the widget function moot?

    I posted a thread here some time back, but never got a response:
    http://wordpress.org/support/topic/101506?replies=1

    I’d be interested to know what everyone’s take on it is. Back when they had the ratings system at themes.wordpress.net, our themes were pretty much ignored and given bad ratings because they weren’t widget ready. Personally, like Emily Litella (most of you are prolly too old to get this but I’m gonna say it anyway), I don’t see what all the fuss is about widgets. 😛

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    jonimueller: You have asked a few different questions here. I’ll see what I can do…

    1. Conditional code:
    Basically, you’re looking for other peoples plugins and adding sidebar chunks for them if they are there. With a widgetized sidebar, you could move this sort of thing to the functions.php file. It’s quite possible to create a widget in functions.php, and you can use a conditional code to create the widget if that plugin is available to you. This gives the person the option to use your widget in their sidebar if they have the appropriate plugin to do so. Creating a widget is really not difficult.

    2. Is it necessary to do so? Your call. If that plugin has an update to make a widget that uses it, then obviously not. Unless you want to make a special widget to work better with your theme or something.

    3. The fuss about widgets: When blog owners install themes, the almost always have to edit them to make their sidebar look the way they want. Quite often, it’s the only thing they’ll ever edit about their theme. But they *always* edit the sidebar. The purpose of widgets is to allow them to do this without having to know PHP. The reason for it being a plugin is a) to sort out the kinks and b) to get plugin and theme authors to start modifying their code. Because don’t kid yourself, widgets will go into the mainline code at some point. Supporting them now gives you a heads up for the eventual support for them in future revisions.

    Thread Starter dwzemens

    (@dwzemens)

    EDIT — Pilot Error, Ignore this Question.

    OK, back to the original thread — I got the widgets working on one blog install, but I am using exactly the same functions.php, sidebar.php code and installing the widgets plugin on another blog site and they do not work?

    Any generic ideas?

    – dz

    Thread Starter dwzemens

    (@dwzemens)

    One more question, if you could point me in the right direction: I have the sidebar widget working great. How do I add a *second* sidebar to the them that also has widgets?

    Thanks for the terrific responses,

    -dz

    Alex Cragg

    (@epicalex)

    create another php file based on the original sidebar as a start, and altar to show other content. create another <div> class or id, then for that new class/id, change the css so it goes where you want it.

    A classic would be to float the first left, the second to float right.

    to get that sidebar to display, (cause it isnt a default template) use something like:

    <?php include (TEMPLATEPATH . '/newsidebar.php'); ?>

    in your index.php file.

    i think this would create two dynamic sidebars…one in each php file

    <?php if (function_exists('dynamic_sidebar')) {dynamic_sidebar(1); } ?>

    <?php if (function_exists('dynamic_sidebar')) {dynamic_sidebar(2); } ?>

    then in your functions.php, put
    `<?php if (function_exists(‘register_sidebars’)) register_sidebars(2)); ?>

    i think…….!
    can anyone else confirm this is right?!!
    😀

Viewing 15 replies - 1 through 15 (of 42 total)
  • The topic ‘Widget Ready — How much work?’ is closed to new replies.