Boxes are custom “bolt-on” applications similar in function to WordPress plugins. However, boxes are much easier to create and share a common code base with Thesis 2.0 and other boxes. In this part of the seminar we look at the structure and content of a Thesis box.
This is a set of files that was created by one of the developers on Thesis. And this is something else I’m going to make available under Live Question and Answer code on my forum. If you use Textmate as a code editor, it has a couple of shortcuts for Textmate. But if you don’t use Textmate as a code editor, it doesn’t do anything for you except that it does have 2 sample boxes. It has this sample advanced box.php and simple box.php.
Anatomy of the Advanced Box
It’s useful to look at the advanced box just to understand some of the parts. Essentially, a box consists of a folder with the box name or the box class name, really, but the box name and then with a file called box.php.
If it’s not called box.php, Thesis doesn’t pick it up. So it’s got to be called box.php but when you have this box.php, that needs to have this header first. And so this header essentially is the name of the box and this is very similar to the WordPress system of plugins.
You have the name of the box, you have the author, you have the version number, you have a description that shows up in the add/remove boxes section, and then you have the absolute important class name. And this class name needs to show up in the extended class here. And what you do is then you create this extended class, class class name, in this case, byob orbit helper extends Thesis box.
Multiple Instances of a Box
Then you have these methods that are existing and are included in part of the Thesis box that you can access. The first one is translate and it absolutely needs a name but if you’re going to have more than one, it also needs a title. I’m sorry, it absolutely needs a title, not a name, but a title.
It absolutely needs a title because this is what shows up in the HTML editor. However, it doesn’t necessarily need a name but if you want more than one of them then what he recommends you do is just uncomment out this line and this name equals this title, essentially making the name equal to the title.
And then on top of that is it adds a unique… well, that’s the unique identifier and then what it adds on top of that is a unique number so you can have multiple instances of this box.
Member: Sorry, what would be an example of a multiple instance box?
Rick: Well, my orbit helper is an example. You can have as many helpers on there on your site as you want.
Member: Oh, meaning if you plan to use it multiple times?
Rick: If you plan to use it multiple times in a template system.
Member: Gotcha, okay.
Rick: If you don’t plan to use it multiple times…if you don’t give it a name then it could only be used once. If you give it name, you can use it multiple times and you can create multiple instances of it.
Member: So now all these filters you have in your box top php which goes along with your orbit slider box, I’m noticing in your Netbeans, you’ve got advanced box php. Is that something that the dev team gave you?
Rick: This is something the dev team released today.
Member: Oh okay, gotcha. So this basically, as of today, meaning prior to their 2.01 release.
Member: These are their list of filters and functions that…
Rick: No, this is just sort of a tutorial.
Member: Oh okay.
Rick: It’s not really a list of their filters and functions. If you really want a list of that, you actually need to go into wp content themes Thesis library… core? Is it core and API? No, it’s core skin and box php. This really tells you the full range of what’s possible in a box.
Rick: Because you can actually have a function admin and a get option and add site menu and add boxes menu and add post meta and add term options…there’s a lot of stuff you can do that is not documented in this advanced box php.
Member: Stuff like adding checkboxes to your box, that kind of thing?
Rick: Yeah there are a number of members of the development team who are not really php programmers. And I think it’s probably a great thing that they’re there because they come at this looking at it differently. They’ve been testing it and this was written for their benefit so that they could see not everything possible but just get an idea of what’s possible with some documentation.
I’m going to make this available so that you can download it too but it includes the advance box and the simple box. In the simple box you’re going to just do a few things. So in a typical box, especially if you’re not a real hardcore programmer you’re just going to do some simple things.