Build Your Own Business Website header image

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.

Lesson 12 – Part 3 – Adding the Dynamic Content Gallery to the Thesis Feature Box

Difficulty Level -

Filed Under Topics - ,

Listed Under Lesson Subjects - ,

Applies to -

This video is part of our old WP eStore Course Go to our Updated WP eStore Course for current videos.

Welcome back to Part 3 of Lesson 12 of the Build Your Own E-Commerce Website tutorial series. In the third part of this lesson we are going to add the Dynamic Content Gallery to the Feature Box.

Ways to Add the Dynamic Content Gallery

With Thesis there are three ways in which we can add the Dynamic Content Gallery to our site. The first way is through the Content Gallery widget. If we come down here to Appearance and Widgets you’ll see that the Dynamic Content Gallery widget was added when we installed the plugin. So you could add this to a widgetized area simply by dragging this up and dropping it where you want it. In that case you could fill out this widget, give it a title, and put some text after that at the end of the gallery. If you have a smaller rotating gallery that you want to use this is probably a great idea.

However, that’s actually not how we’re going to do it. You can’t do both. You can’t have this as a widget and also use it as a template tag which is the method that we’re going to use. Because of Thesis hooks you can use it as a template tag anywhere. You don’t need to use the Feature Box, you could create conditional language that would say for example, if it’s page 345 then add the gallery to the thesis_hook_before_header and it would be installed just like anything else in Thesis.

Adding the Dynamic Content Gallery with a Template Tag

We’re going to pick the third way which is a simplified method. This way the location is controlled by the Feature Box and we’re just going to hook it to the Feature Box. The way you hook this to the Thesis Feature Box is in your custom_functions.php file.

What we’re going to do is open up our custom_functions.php file in NetBeans. So we’re going to go ahead and start by creating a function here. I’m just going to put it below Header. I’m going to copy all this, paste it, we’re going to call this new function – byob_dynamic_content_gallery and we’re going to say “This function places the dynamic content gallery in the feature box”.

Add the Code to custom_functions.php

Before we even have any code at all we may as well just select the correct action for this –  it’s going to be add_action, thesis_hook_feature_box and then it’s going to be byob_dynamic_content_gallery.

Now what we’re going to do is add our code and we want to ask the question “if the plugin is installed” – and if the plugin is installed then we want to add the template tag. We’re going to get that code from the Dynamic Content Gallery website. Let’s go back to our Dashboard and open up the Dynamic Content Gallery, if we scroll down here to the bottom they’ve got their list of help and support sections. Go to Documentation and scroll down here to How to add the Dynamic Content Gallery to your Theme. Expand that and this is where we’re going to get our code.

Now there’s a nice simple method of doing this but I don’t think it’s nearly as safe a method because you might uninstall the gallery and then this would break your site. So what we’re going to do is to pick the version of the code that asks the question “if the function exists then add this template tag”. We don’t need this little php tag so we’re just going to steal the code from there to there, copy it, come back over to our editor and paste it.

So now it says if the dynamic_content_gallery function exists then do this function, dynamic_content_gallery, which is the template tag that calls the function and that’s all we need here. We’ve got a function name, we’ve got an add_action to the function name and we’ve got a function exists, dynamic_content_gallery. Let’s go ahead and save it.

Open up Filezilla, connect up to our site and go to themes, thesis_18, custom and then down to custom_functions.php which we’ve just edited and upload. Now let’s go take a look and see what happens on our site. You can see that a content gallery shows up here. Now we have to put images in it because right now all it’s doing is bringing up Hello World.

That wraps up Part 3 of Lesson 12 of the Build Your Own E-Commerce Website tutorial series.

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
0 Comments… add one
0 comments… add one

Leave a Comment