Widgetizing Thesis’ Multimedia Box

by Rick Beckman on January 2, 02009

What bet­ter way to start my blog­ging blog than to share a tip for Word­Press blog­gers using the world’s best theme?

The sub­ject of The­sis’ mul­ti­me­dia box comes up quite a bit on our sup­port forums, with users want­ing to do a vari­ety of things in that area. (Hon­estly, I’m con­vinced that every theme needs a mul­ti­me­dia box akin to The­sis’; users are doing all sorts of amaz­ing things with it!) One of the ques­tions I haven’t been able to answer up to this point is how to wid­getize the mul­ti­me­dia box area, allow­ing for far more cus­tomiza­tion with­out the need to write or even copy a sin­gle line of code.

The answer comes from one Adam Bar­ber (@adambarber), and the solu­tion was eas­ier than I ever thought!

All that’s required is a sim­ple addi­tion to your custom_functions.php file:

register_sidebar(array('name' => 'Multimedia Box', 'before_widget' => '<li class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3>', 'after_title' => '</h3>'));

function multimedia_box_widgets() {
	echo '<ul class="sidebar_list">';
	dynamic_sidebar('Multimedia Box');
	echo '</ul>';
}
add_action('thesis_hook_multimedia_box', 'multimedia_box_widgets');

The first line reg­is­ters our new “side­bar,” or wid­getized area. We use the same options as used by The­sis’ default side­bars, but we name the area some­thing mean­ing­ful for our pur­pose: “Mul­ti­me­dia Box.”

The third through sev­enth lines cre­ate the func­tion which out­puts our new wid­getized area. Ordi­nar­ily, only the sec­ond through fourth of these three lines is needed, and it would be placed in the theme files where we want the wid­gets to appear. How­ever, with The­sis, in order to facil­i­tate the eas­i­est pos­si­ble upgrade expe­ri­ence, we pre­fer to keep all cus­tomiza­tions within the custom/ folder, and we wrap the code we want to add within a func­tion (or, action) which can then be hooked into the appro­pri­ate place within The­sis, which is what the final line of the code does.

Once you have added the code and uploaded the file to your remote The­sis custom/ folder, you will be able to select a new wid­getized area in the Appear­ance » Wid­gets panel of your site. In the Appear­ance » The­sis Options panel, set your mul­ti­me­dia box to use “cus­tom code.” That’s it!

Now, per­haps you want dif­fer­ent items appear­ing on the mul­ti­me­dia box depend­ing on which page you’re vis­it­ing; no prob­lem! Because this is now a wid­getized area, you can con­trol it via the likes of the Wid­get Logic Word­Press plugin!

{ 40 voices in the conversation. Speak up! }

t April 3, 2009 at 18:14

I followed your instructions exactly and copied and pasted the code. When I add widgets to the mm box they show up ok but it repeats at the bottom of the sidebar. Any suggestions..

Tinh April 15, 2009 at 05:22

I does not work properly and I had errors. Pls advise

Rick Beckman April 15, 2009 at 19:42

For that, I would need to know what errors you were receiving. ;)

lavenedora April 27, 2009 at 16:22

Is it still necessary to alter custom_functions.php for this if we are using your Open Hook? Excuse my ignorance, Rick, but you have created a fairly new reply to this thread, and you don’t mention Open Hook anywhere. If we can use Open Hook, we’d put the 2-4 lines, where? Multimedia box? Or, is it something you still have to alter the file manually to do? I’ve been unsuccessful with any customizations that require changes to custom_functions.php.

Also, I’ve been having lots of difficulty with customizations in general, even with Open Hook–everything results in a “parsing” error. I don’t know where I can post a general request for help with these errors–please point me in the right direction. There has to be a simple solution.

Rick Beckman April 27, 2009 at 18:33

lavenedora: There’s an area for OpenHook support on the official DIYthemes support community, so feel free to seek help there.

However and unfortunately, the above code likely won’t work in OpenHook. The first line of the code must be active when the admin panel is called, and none of OpenHook’s boxes perform any action at all within the admin panel.

Open your custom_functions.php file, and add the code to the very end of the file. Should work fine, but let me know if it doesn’t.

lavenedora April 28, 2009 at 16:02

Thanks, Rick. I’ll give it a try and let you know if there are any issues with plugging it directly into custom_functions.php.

t April 28, 2009 at 16:21

For some reason the plugin isn’t working anymore. It was before. Even when I try and add an image through my custom_function file it doesn’t work. What do you think could be the issue?

Rick Beckman April 28, 2009 at 18:30

t: Do you mean OpenHook isn’t working? If so, drop by the OpenHook support forum on the DIYthemes board and explain the situation — Thesis version, OpenHook version, the exact code you’re using, and so on. Thanks.

t April 28, 2009 at 21:49

I went to the diy forums but didn’t see a forum for open hook support just a support for 1.5. Is that where I’m supposed to post it?

t April 28, 2009 at 21:55

I found it but I can tell you here what’s going on…

I’m running 1.5 v7

I’m trying to create a box and place it with the plugin…

Here’s what I put in the after header

<div class="commentbox"></div>

Here’s what’s in my custom.css

.custom .commentbox {border: solid 1px; height: 50px; width: 300px; background: #eeeedd;}

Here’s the problem. It showed up fine, then i refreshed and it disappeared. Then I inserted the word "test" between the div tags. It showed up. Then I got rid of the word "test" and just inserted a "t" and the box disappeared again but the "t" showed up . Then I got rid of the "t" and nothing showed up again. Then i put the word "test" in there and just the word "test" shows with no box.

The box did show up once but I can’t get it back. Any suggestions???

lavenedora April 29, 2009 at 13:19

Hey Rick,

Wooo hoooo . . . Thanks again for your help. I got the widgetized multimedia box going. How easy & how cool!

jon soroko May 5, 2009 at 14:38

Rick,
In the Appearance | Editor window – I don’t have a custom_functions.php file – I do have “custom template” and “functions”
But not custom_functions
What am I missing here?
Jon

jon soroko May 5, 2009 at 14:49

Rick
Found it via FTP – added the additional lines – in Notepad++
then uploaded it.
In Appearance | Widgets – don’t see any change.
Advice?
Jon

gabe June 23, 2009 at 20:15

does this become sort of obsolete with the open hooks plug-in?

Rick Beckman June 23, 2009 at 21:23

Not necessarily. OpenHook lets you easily add content to the Multimedia Box, but it still isn’t widgetized. If you want to easily add widgets to the multimedia box, then the tutorial is still relevant. Although, I’m not sure it even works these days. May have to revisit it when I have the time.

JW July 31, 2009 at 17:37

Using the MM Box Widget created with your simple, much appreciated coding, I would like to put different videos on different pages. How do I do that?

Thanks in advance.

Rick Beckman July 31, 2009 at 17:47

If you’re going to accomplish that with widgets, then you’ll need to use a plugin like Widget Logic to control which widget appears on which page, then add numerous Text widgets, each with the code to display a different video. Each widget can then be set to display in a different context using Widget Logic’s controls.

JW July 31, 2009 at 18:11

Ah so!
Thank you for the quick reply…and for all of the work that you do!

Tina August 3, 2009 at 07:56

OMG I messed up. I was trying to create a custom 404 page and changed the custom_functions.php page and now I cannot get back into it on the site!!!

Please HELP!!

Thanks,,

Tina

Rick Beckman August 3, 2009 at 13:19

Remove the code you added to the file. Replace it with an entirely blank file if you have to; there’s likely a syntax error in your code that you’ll need to track down before you’ll be able to use the code on your site.

For further help, ask on the Thesis support board. Thanks.

Tina August 3, 2009 at 13:43

Thank you Rick! I actually did get into the ftp area and accessed the file; removed what I added and it is acting better. At least I am able to log back into the admin pane/dashboard, but I keep getting other weird errors that I can only chalk up to this mistake. I did save the originally customized php file with an extension and will always have that now if needed.

I appreciate your time; thanks again.

Tina

Thomas August 24, 2009 at 09:09

ich have successfully widgetized the multimedia box. Thanks Rick!
But if i put a widget like Killer Recent Entries in it, then this widget got no styling like the other widgets in the sidebar.
How can i set up the styling for this Multimedia Box Widget?

Christine Green May 15, 2010 at 22:46

Rick,
Thanks! This is great. And I had just recently discovered Widget Logic which is fantastic. Is it possible to move the MM Box to the the left sidebar panel ?(using 3 columns on a site) – or any other place also? I’d love the flexibility of moving the box.
Thanks!

Digital Pill May 17, 2010 at 07:27

Yikes, Hi Rick this doesn’t seem to work for me.. :(

The multimedia box looks good for the homepage, but when you click though to individual post pages, it shows the article image in its place of expected video for some reason.. So it looks like its not picking up the setting somehow.. Any idea where I can look? I want to use widget logic eventually..

Rick Beckman May 17, 2010 at 11:39

I think the article image takes precedent. Disable that on the individual articles and you’ll probably be fine. If that’s not the case, you’ll need to ask at Thesis support. I’ve not used the theme for several versions now, so it may not be behaving like I was used to anymore.

Bill June 14, 2010 at 23:22

Box is up and running just fine. I’m using an image widget. Is there a way to get some styling in there – font size, color, different headline font, padding between copy and image so I can move it to the left side of the widget? Thanks…

Rick Beckman June 15, 2010 at 02:09

You’d have to view the source of your page (or use Firebug to inspect it) so that you know exactly which elements/classes/IDs you want to target, then you could easily add whatever styling you want to your custom stylesheet targeting the aforementioned elements/classes/IDs. Because there is a theoretical infinite combination of answers due to every setup, every widget, and every customization being slightly different, I can’t really be more specific.

tori July 4, 2011 at 18:04

I did this and when I went to Appearances and clicked on it I get this error message:

Parse error: syntax error, unexpected $end in /home/potatot1/public_html/wp/wp-content/themes/thesis_181/thesis_181/custom/custom_functions.php on line 18

I ran the script that I entered through an online php validator and it said there were no syntax errors. Line 18 (if I’m counting correctly) is just the closing bracket.

tori July 4, 2011 at 18:09

Now when I go back to the Manage Themes page I’m getting this at the top of the page. Can’t seem to get rid of it.

Warning: Cannot modify header information – headers already sent by (output started at /home/potatot1/public_html/wp/wp-content/themes/thesis_181/thesis_181/custom/custom_functions.php:1) in /home/potatot1/public_html/wp/wp-includes/functions.php on line 861

Warning: Cannot modify header information – headers already sent by (output started at /home/potatot1/public_html/wp/wp-content/themes/thesis_181/thesis_181/custom/custom_functions.php:1) in /home/potatot1/public_html/wp/wp-includes/functions.php on line 862

tori July 4, 2011 at 18:10

It’s also on my Site Options page. Should I reinstall Wordpress and Thesis?

tori July 4, 2011 at 18:14

There are no extra spaces in the php file…

Rick Beckman July 4, 2011 at 20:13

The error message indicates that something is being output to the browser by your custom functions file, and it’s outputting in the very first line of that file.

Are you sure there is no extra space before the opening <php tag?

tori July 4, 2011 at 22:16

Yes the opening tag is right up against the left side corner. I put the cursor there to make sure there’s no space.

The worst thing is even though I have deleted the code I added, I’m still getting the error messages.

This same kind of thing happened with another customization I tried to do. I ended up reinstalling everything. Replacing the edited php file with the original from the zip file didn’t help.

I feel so stuck! Was just getting started with Thesis and can’t get anywhere.

Rick Beckman July 4, 2011 at 23:44
tori July 5, 2011 at 21:48

Rick, thanks so much for your email help!! I’m feeling a lot less discouraged now…:-)

Tori

Rick Beckman July 5, 2011 at 22:49

I’m glad you got everything up and running again, tori. I’m also surprised my code above that you used still works. It’s over two years old!

Scott September 27, 2011 at 14:14

Hi Rick – thanks for the tip!

I added the code successfully and now see the Multimedia box in my Widget area. Unfortunately it doesn’t appear to work, though. I can add any widget to the box in Multimedia Box, save it, but nothing happens to the page result. Thesis’ default images remain.

I’m grateful for any help or guidance you can provide.

Thanks, Scott

Scott September 27, 2011 at 14:17

Lol – oops, I missed a small, but very important step in the process – setting the custom code option in the multimedia box settings. Works great. Thanks sir!

Milind November 7, 2011 at 21:04

Hello
I have a small question and be grateful if you could answer.

I am using a header background, but since I moved the MM box up, the background stops where the mmbox starts. How to overcome this obstruction? Any ideas? Thanks.

Rick Beckman November 7, 2011 at 22:38

If the site in question is the one your name is linked to, you can get a more attractive result by adding this to your custom.css style sheet:

#sidebars { margin-top: 1.3em; }

Leave a Comment

{ 9 linkbacks }

Previous post:

Next post: