Build Your Own Business Website header image

What is the $depth Variable in the HTML Output of Thesis 2 Boxes?

Difficulty Level -

Filed Under Topics -

Listed Under Lesson Subjects -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

In this session we explain the $depth variable in the HTML output of Thesis 2 boxes. With Thesis 2.0.3, Thesis has started passing a block of arguments, $args, to HTML for you to hook onto; one of the most common ones is $depth which is a number. It allows you to add tabs in front of the HTML elements. To learn even more about $args, go to Lesson 6 of our Create a Responsive Skin for Thesis 2.0 course.

Video Transcript

Member:  But my question today is regarding boxes.

Rick:  Yeah?

Member:  And with where you got your… you sort of do the results of box in the public function html, I see a couple of variables in there. One is sort of depth and the other one I sometimes see is args = false. What are those and what do they do?

Rick:  Okay so the args… and I do have kind of a full description of this in the Lesson 6 of the Responsive Skin class. But in Thesis 2.03, Thesis has started passing a block of arguments to HTML for you to hook on to. The most common one is depth. And so what you’re doing when you say args = false here is all you’re doing is initializing the variable args so you don’t get a warning. So you start off with the args = false and then Thesis automatically passes args to the HTML function. So then when you extract the args, you are extracting the array args. And when you extract the array args, you are getting an array of stuff. The most important of which is depth.

And actually, this is a very poor… I didn’t notice I… look at that, I screwed that up because you can’t use args as a variable here again, without screwing this whole thing up. So I just used, in this box, I used args as a variable and that does not work. Args 2… where is my args 2? That is going to throw things off because args is already defined up here.

So args contains… one of the array elements in args is a value called depth. And when you extract the args, you extract this array into individual elements, each with their original name. Depth happens to be the name of this.

And depth is a number. And what depth does is essentially, allow you to add tabs in front of your HTML element. So what you end up with is essentially 3 parts. You’ve got args equals false. You’ve got extract args and then you’ve got tab = string repeat and you’re repeating the string/t which is the tab. And you’re repeating it, the number that is contained inside the variable depth. And then if depth… I mean, if depth isn’t empty then you’re repeating it from the number of depth and if it is empty then you’re just… then depth = 0.

And so then down here, you’ve got the tab, right? So tab tab tab tab… and that way, when somebody looks at your HTML, it looks… view page source. You know, it’s all nicely tabbed.

Member:  So in other words, it just stops you from having to remember to pop in the slashes and the t’s.

Rick:  Exactly.

Member:  I think it doesn’t work a new line. It’s just the t’s, yeah?

Rick:  Well, it is… the new lines do get… it is just the t’s, yes. It is. But you can see it ends up happening here then because you got the main div and then tab tab and then tab tab and then that kind of stuff. So that’s what that’s for.

Member:  Super. Great, okay. Thank you.

Rick:  Because I never use them, I’ve forgotten what the other arguments are. But if you go watch that video on the first… I think it’s the first video on Lesson 6. I have a little thing where I talk about each of the different arguments. But I only use depth myself.

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
THIS IS A LIMITED TIME OFFER!
Subscription Options
0 comments… add one

Leave a Comment