Forums

[resolved] Making a standalone sidebar widget (17 posts)

  1. Fretless
    Member
    Posted 5 years ago #

    Hi guys. I've been working on this for a couple of days but with no luck, and I've searched through the forum but still haven't found what I'm looking for. So I've decided to finally ask some of the extremely helpful people here for advice.

    I've just recently "discovered" widgets, having never bothered to use them before. I currently have a theme for my blog which is based on Kubrick, so "widgetizing" it has been pretty easy.

    The main problem I have though is that I have a customized sidebar, with images instead of text for categories, archives, meta etc. Of course when I use widgets on my theme I lose this feature in my sidebar and it just reverts back to text.

    So basically I would like to know if there is an easy way to make the Kubrick sidebar into a standalone widget? I've tried the various php/text widgets but they haven't seemed to work. The css is messed up for one thing and the images don't show. If someone can help with the sidebar widget code I would appreciate it very much. If I can get it to that stage then I should (hopefully) be able to just overlay the standard Kubrick sidebar with my custom one.

    Thanks in advance.

  2. Zoutesnor
    Member
    Posted 5 years ago #

    Its pretty easy. In your wp-content/plugins/widgets directory, create a file called sbar.php (or any other name you like), and insert the following code:

    <?php
    /*
    Plugin Name: sbarwidget
    Plugin URI: http://
    Description: Adds a sidebar widget for ...
    Author: You
    Version: 1.0
    Author URI: http://
    
    */
    function widget_sbar_init() {
    
    if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	function widget_sbar() {
    
    		echo $before_widget;
    /* put your code here */
    
    		echo $after_widget;
    	}
    
    	register_sidebar_widget('Sbar', 'widget_sbar');
    } 
    
    	add_action('plugins_loaded', 'widget_sbar_init');
    ?>

    This is pretty much a basic framework for a sidebar widget.

  3. Fretless
    Member
    Posted 5 years ago #

    Thanks Zoutesnor, but I keep on getting syntax errors when I try your code. Usually with '<'. Any ideas?

  4. amusedcy
    Member
    Posted 5 years ago #

    Hi, I have a related question....where do I find the wp-content/plugins/widgets directory ?? I've read all the info on uploading plugins, but I don't know where this directory is.

  5. Fretless
    Member
    Posted 5 years ago #

    I should add that I'd be willing to pay for a working widget if the price was reasonable. I know that it's a quick and easy job for a skilled coder (which I'm not) to do, so I guess that should keep the cost down. I'd also pay through PayPal if anyone is interested.

    Basically I'm looking for the entire Kubrick sidebar made into a working widget. Any takers?

  6. Zoutesnor
    Member
    Posted 5 years ago #

    Could you give me an example of a syntax error (complete error code)? Usually this happens when you're trying to put html code inbetween php code. Try in the example above to do this:

    echo $before_widget;
    ?>
    <!-- put your code here -->
    <?php
    echo $after_widget;
  7. Fretless
    Member
    Posted 5 years ago #

    amusedcy> You create it, from memory. Just create a widgets folder inside your plugins folder.

  8. Fretless
    Member
    Posted 5 years ago #

    Zoutesnor>> No syntax errors that time, but nothing showed up in the sidebar, and my page was hellishly long and without a footer.

  9. amusedcy
    Member
    Posted 5 years ago #

    Ah, I just found it. It was in Options/Miscellaneous

  10. amusedcy
    Member
    Posted 5 years ago #

    To clarify: what I found in Options/Miscellaneous was:
    wp-content/uploads

    I also found this help page elsewhere in WP:
    http://codex.wordpress.org/Managing_Plugins

  11. Zoutesnor
    Member
    Posted 5 years ago #

    My bad, you should get rid of the comment tags, the <!-- and --> thingys.

  12. Zoutesnor
    Member
    Posted 5 years ago #

    And you're willing to pay for something which would take about 2 minutes to build and upload? Wow. Here you go (it's on the house).

  13. Fretless
    Member
    Posted 5 years ago #

    Thanks Zoutesnor. Much appreciative of your time. The code almost works, but it outputs everything to the far right (over the background) rather than in the actual sidebar. Any ideas about that?

    I thought that it would be much better to pay someone who's much more proficient with php than I am, rather than screwing around with it myself (and getting frustrated with the results). I'm not a programmer so I thought I'd leave it to the experts.

  14. Fretless
    Member
    Posted 5 years ago #

    By the way, glad you sorted your problem out, amusedcy.

  15. Fretless
    Member
    Posted 5 years ago #

    I think I've worked this out now. I removed < div id="sidebar" > and that seemed to sort out my alignment problem. I did have bullets all over the place on the sidebar though but I removed the top and bottom < ul >< /ul > and that seemed to work. Am I likely to have any layout problems by doing this however?

    Thanks for all your help, Zoutesnor. Much appreciated!

  16. Zoutesnor
    Member
    Posted 5 years ago #

    After I posted it, I was afraid the things you said where going to happen. But I think you've solved it in the right way.

  17. Fretless
    Member
    Posted 5 years ago #

    Everything seems to be working wonderfully. Thanks again for all your help, Zoutesnor.

Topic Closed

This topic has been closed to new replies.

About this Topic