If you want to integrate a SmoothGallery into your theme you can use the WordPress SmoothGallery plugin. There’re two ways to do this:
- You want a gallery in your sidebar? Use the widget.
- You want a gallery somewhere in your theme? Follow the developer howto.
Sidebar widget
The plugin comes with a widget that displays a gallery in your sidebar. This way it’s very easy to insert a gallery because you don’t need to know how to write PHP code. Since the widget renders the gallery inside an iFrame you can add as many galleries as you want.
There’re various options that you can change on the edit screen for every widget. The first thing you should do though is supplying the ID of a post or a page where you uploaded the images. Once you’ve done that the widget should work as expected displaying the images from the given post/page. If it doesn’t work check the value for imgsize: this has to match the values for the thumbnails under Settings – Media.
Developer Howto
All you have to do is to implement the function insertSmoothGallery in the file config.php; you can find it under wp-content/plugins/smoothgallery. Depending on your implementation the plugin makes sure that the CSS and JavaScript will be included inside your page; keep in mind that this won’t work if the SmoothGallery sits inside an iFrame.
Let’s say you want a timed gallery on the page with the id 4711 somewhere in your theme that’s 400×80 pixels. Open the file config.php and implement the insertSmoothGallery function like this:
function insertSmoothGallery() { # add all the conditional tags you're using to the array if (assert_functions_exist(array('is_page')) === false) return false; if (is_page('4711')) { return array('width' => 400, 'height' => 80, 'timed' => 'true'); } return false; }
Once you’ve done that put the HTML markup for the gallery somewhere inside your theme and you’re all set. No matter how you implement the function don’t remove the call to assert_functions_exist.
As you can see, I used the conditional tag is_page. These come in handy if you’d like to display the gallery on some specific pages only – if you don’t want that but a gallery on each and every page just remove the if statement and the corresponding curly brackets.
Just add another sidebar…
Instead of implementing the clumsy insertSmoothGallery function you can simply add another sidebar to your theme if you like that better. Think of it as a placeholder for widgets. It doesn’t necessarily have to be a vertical bar on the side – some horizontal thing in your header or footer is okay too.
So, maybe you want to have a look at the Widgets API and learn how to add another sidebar to your theme. Check out register_sidebar and dynamic_sidebar in particular; the page about the second function tells you how to manage Multiple Sidebars in your theme.
I wrote a post about adding a sidebar to your theme, just three easy steps that should be easy to follow if you’ve got a basic understanding of PHP and themes in WordPress.
Still not convinced? Maybe you’d like to read Ian Stewart’s We Need To Kill The Sidebar.
99 comments ↓
“Plugin could not be activated because it triggered a fatal error.”
Message.
I’ve tried deactivting all my other plugins, and checked for the call to the header and footer, but no luck.
Any ideas what the problem might be?
please have a look at this comment.
I’ve uploaded the plugin and activated it, but when i put
in to my Main Index Template all that shows up on my page is the actual words and it doesn’t show the plugin.
you’ll have to edit the file
smoothgallery.phpthat comes with the plugin. Open it and search for the functioninsertSmoothGalleryand insert your code there.You can see it here … http://www.bodycreativenetwork.com
Any help would be greatly appreciated, thanks!
Do I have to put include smoothgallery.php? how do you do it?
This video shows you how I did it.
Activate the plugin, implement
insertSmoothGallery, insert the markup in your theme and you’re done. If it still doesn’t work read the FAQ or write me an e-mail.Thanks for providing us with this plug-in which we can use. I have a question though regarding integrating the plug-in within the site for the latest articles.
On my home page, I currently have a tabbed feature where my latest article is displayed. What I would like to do is replace that with the SmoothGallery plug-in so that it would grab the three most recent articles and their related images.
I was trying to use the code from your example on the front page, and wrapping that around the existing code in my theme which displays the latest article, but with no luck. Can you provide us with a way to integrate the plug-in in that fashion? Or at least point us in the right direction?
Thanks.
This should be the feature you were looking for…
That’s the HTML markup for the gallery. Thanks for the hint!
All other pages give the error: invalid argument supplied for foreach() ….[file location] smoothgallery.php on line 94. This line is looking for key values but finds none since the gallery is only on the one page.
What do I add to smoothgallery.php to avoid this little error?
in smoothgallery.php: make sure you double check your work when adding function insertSmoothGallery. Don’t change return false;.
I tired to enter the code below into my wp-config.php file. Because of a statement below the code, according to the instructions as to how I understand it. I didn’t see a config.php file so I used the wp-config.php file. I also installed the smoothgallery files into my plugin directory.
Now I just get this message when I get to my site.
Parse error: syntax error, unexpected ‘}’ in /home/jaxel/public_html/sodafox/sodafoxblog/wp-config.php on line 28
(code inserted)
function insertSmoothGallery() {
return array(‘width’ => 400,
‘height’ => 50,
‘timed’ = ‘true’);
}
(instructions)
If you want to integrate a SmoothGallery into your theme you can use the WordPress SmoothGallery plugin. All you have to do is to implement the function insertSmoothGallery in the file config.php.
have a look at the directory
wp-content/plugins/smoothgallery: you’ll find aconfig.phpthere. Insert your code into this file.Thanks for this fab plug in! I’m just having trouble getting it to work. I amended the congif.php file in the smoothgallery folder:
And then I inserted this code in my home.php file
And it is coming up with just words on the page. See http://corkermag.com/blog/
What am I doing wrong?
Thanks in advance.
I am trying to install the plugin on my home page and I get nothing.
Here is what I did:
1. uploaded & activated the plugin
2. added this code to the config file (in the plugin directory):
3. placed this in my header file:
insertSmoothGallery();4. in homepage file:
insert_recent_images_box(5);5. created a test post with an image.
Nothing displays on the home page. I want the carousel to display the images from the last 5 posts.
What am I missing?
Thanks.
step three isn’t necessary. Have you used WordPress’ built-in Media Library to upload and attach the image to the post? Have you tried using the special tag inside the post? Does the latter work?
And is there a “Gallery Set” function?
Thanks a lot from Ukraine
I haven’t tested the plugin with WP 2.0 but just give it a try
If you want images from some set in a gallery you have two options:
Since the second option currently doesn’t work and if you’re using WP 2.0 you won’t have the “Media Library” (do you?), so option one isn’t possible either. I suggest, that you update WP to 2.5 or wait until I’ve included support for images from Flickr.
I’m experiencing a bug in FireFox. The gallery loads, there’s a black flash on the screen, then the first image fades to white before the second loads without the fade transition.
The page is the link I’ve set in the website field in this comment form. I’ve got the gallery loading as part of my theme so I haven’t included the smoothgallery custom field.
Any ideas?
Cheers,
Robert
hm strange, I can’t see the error here and I’ve tried it with Firefox (2.0.0.14) and Safari (3.1.1): the transition looks fine for me. I’m sorry, but I can’t help you with that.
BTW: If you’ve integrated the gallery into your theme with the
insertSmoothGalleryfunction, you don’t need the custom field. So that should be okay.I was looking for a plugin that will show images in a nice way and I was glad I stumbled on your plugin. I want to integrate nextgen smooth gallery in the theme. I’m not a coder so I rely on cut-and-paste instructions.
But I was stumped with the how to on integrating it with the theme.
First, the plugin directory of the site I’m working on looks like this…
mydomain.com/wp-content/plugins/nextgen-smooth-gallery/
Do we have to rename the nextgen-smooth-gallery folder to smoothgallery?
Inside the nextgen-smooth-gallery folder are the following:
1. /smoothgallery ==> another folder
2. nggsmooth.php
3. nggsmoothframe.php
4. nggsmoothsharedfunctions.php
5. readme.txt
Inside the /smoothgallery folder are the following:
1. /CSS ==> another folder with images and CSS.
2. /Scripts ==> a folder with JavaScript files only.
3. License.txt
My best bet for what passes as config.php is nggsmooth.php so I placed the function insertSmoothGallery there above all the other functions. My dashboard went blank. I also watched the videos.
BTW, I have NextGen itself installed and running. Fact, the the images are showing great in the plugin settings page. If I can only make it appear on the front page… this is embarrassing but I’m also lost on the HTML mark-up to insert the gallery into the index.html or home.php.
Thanks.
this plugin is just about SmoothGallery – if you’d like to integrate SmoothGallery with NextGen, you should ask these guys.
However, if you decide to use this plugin I will of course help you to integrate it on your website; just write me an email.
I am integrating this into my theme, but it displays the box with the arrow but no image. I am so close! I have checked the path to the image and it’s there. I am stumped. If you have any ideas I would really appreciate it.
-Gregg
Nice Plug-In you got going here. I’m trying to install it, but once I do all the steps you’ve put in the instructions I get no change visible. I’ve activated the plug-in, and pasted the markup text in the main index template so that it would show up after the header. I then went into the config.php, saw this
Which I then replaced with this
Fatal error: Call to undefined function insertsmoothgallery() in wp-content\plugins\smoothgallery\smoothgallery.php on line 94
I have added the code to
config.php:The plugin seems to be breaking the
wp_header()code on WordPress 2.6.1.im having some trouble with installation.. i did everything youve requested (im trying to include the plugin as part of my theme on the home page i.e. display featured posts) and you keep mentioning insert the HTML markup in the header.
Could you please tell me WHAT html markup? im new to programming so i have no idea how to call the plugin on my home page?
PS i think a lot of people are trying to use this to display their featured posts… maybe a tutorial just on that???
thanks!
The plugin displays the images and everything but I get an error message at the top and bottom of my page saying:
Warning: Invalid argument supplied for foreach() in /home/.minni/xxxxxx/iphonedownloadblog.com/wp-content/plugins/smoothgallery/smoothgallery.php on line 97
Line 97 is : foreach ($parameters as $key => $value) {
I really don’t know what to do here.
Any help would be greatly appreciated. Thanks
if you changed the
insertSmoothGalleryfunction and it doesn’t returnfalseor an array that holds the options for the gallery, theforeachstatement will break apart.Just replace this function with the original one and everything should be okay. If you want to integrate the gallery into your theme and you want to change that function make sure to either return an array or
false.Leave a Comment