In this session we show how to hide the subcategory drop down menu in Shopp. In category.php, we add code that asks if the Shopp collection has the subcategory and if so then the drop down menu appears and if not then the menu will not appear.
Rick: What are we doing tonight? We’re getting rid of this little thing?
Member: Yeah, try to get rid of that funky box.
Rick: okay so then we’re going to do a little programming solution to this. And what we’re doing here is we’re going to ask the question… we’re not going to show this subcategory list unless there actually is a subcategory. So that’s what we’re doing here.
Member: You’re going to tell it to do that, okay.
Rick: Right. And so the function that we’re going to use is Shopp collection has categories. And it’s essentially this, if Shopp collection has categories. Now the thing about this is what this… this isa little misleading in its language because it’s wondering whether or not it’s a collection and if it has categories. But what this really does is it checks the current category and asks whether or not subcategories exist for that category. Don’t ask me why it does this… I mean, why it says it that way. But nevertheless, that’s what this is supposed to do. And so that’s what we’re going to do here is in this code right above that section where it’s going to show the dropdown list, we’re going to ask first if the Shopp collection has categories. And if it does then we’re going to display that category. I mean, it will display this. And if it doesn’t, we won’t. PHP and then we’ve got our closing bracket and then there.
So now, we have this little if statement, if Shopp collection has categories. So if there are subcategories then show the dopdown category list. If there isn’t, nothing’s going to happen. So that’s what’s happening here.
Rick: So we save that, we upload it back to your system and if this doesn’t work, I have a homework project.
Member: Oh come on, we need one here.
Rick: I know. It’s time to take… get a win for the team here.
Member: Yeah, that’s right. We’re due with this particular issue.
Rick: There it is.
Member: Oh, look at that. Alright, good job, Rick.
Rick: Okay, perfect. Now there’s…
Member: I don’t know mean to be picky but that other thing there, recommended? I mean, I don’t hate it but… I guess… okay.
Rick: The thing is, what this does is it sorts your products. So if you’ve only got a single product then you kow, it’s not probably useful. But I’m presuming that you’re going to have more than one product.
Member: Well, not for this category so is there a quck way to turn that off by category? Probably not, right? Because otherwise…
Rick: Well, it’s just another… it’s going to be another question. The question is, in this case, it’s going to be right this order by list. So you’re going to say if the category… well, you’re going to get the number of products in the category. And if that number of proudcts is greater than one then you’ll display the dropdown. And if it isn’t, you won’t display the dropdown.
Member: Okay. Could you throw that in there?
Rick: I can’t at this moment because I got to figure that out.