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.
85 comments ↓
This is an excellent plugin and looks great, so here are the instructions to get it working:
/wp-content/plugins/smoothgallery/config.phpand at the bottom find this:function insertSmoothGallery()… and change it so that it looks like this:Of course, you can change the settings to your needs and image size.
The reason I struggled to get it to work was that I had
ShowCarousel, which was not correct and I happen to come across the correct variable (Carousel). Before I changed that variable I got zip, nada, nothing displaying although I could see that the code found the images ok. I even revertedconfig.phpto its original state and my 5 images would display, stacked. I knew the problem had to be a setting in the plugin.Hope this helps the next person.
Herein lies the problem. I do a test post. I add a couple of images and the plugin does not provide the code until I save. So I save and I follow all the directions in your video: I add the custom field and implement the shortcode. I’ve added the html generated code also and still, It won’t work. If there’s something else I need to do to the files, please tell me step by step because I’m not a programmer.
But I get this error:
Warning: Invalid argument supplied for foreach() in /home/content/e/f/o/efoliomn/html/wp-content/plugins/smoothgallery/utils.php on line 357
I don’t know what to do. Please help.
No you’re not
I’m sure that we’ll get this working!
Can you e-mail me a link to your test post? I’ll have a look at your page to see what might be wrong.
PS.: The error should be fixed in version 1.11.2.
After adding the images you’ll have reload the edit screen. The SmoothGallery panel under Advanced Options won’t pick up the images until you hit reload in your browser or click Save. There’s no AJAX magic involved here.
Any ideas?
Just to clarify the statement above, it’s the css link to the css code (smoothgallery.php) the plugin inserts in the head section of my html that I discovered was returning the 404.
the “HTML markup” is something like the following:
<div id="myGallery"> <div class="imageElement"> <h3>Headline</h3> <p>Description</p> <a href="image.jpg" title="open image" class="open"></a> <img src="image_thumb.jpg" class="full" alt="Image Description" /> </div> <!-- more imageElement div's here... --> </div>So it’s just the HTML describing the images for the SmoothGallery.
I took the function code and posted it in my
index.phpfile. There came an error saying it was already posted in theconfig.php.I want this to show up on the home page ONLY and not all the other pages. Please help…..
just edit the file
config.phpin the plugin’s directory and the plugin will notice it; don’t copy the function to your theme. In case the howto above wasn’t that clear for you to grasp here’s what you should do:config.phpunderwp-contents/plugins/smoothgalleryinsertSmoothGallerylike so:is_homeisn’t working for you.That should be it
smoothgallery > On?
Because that didn’t work with a post.
[smoothgallery].Thanks for the plug-in!
I was able to get the smoothgallery up and running in my header, but when I insert the mark-up into the code for my header, I bump down the rest of the page 300 pixels (the same size as my smoothgallery).
This is likely just an HTML problem, but perhaps others have encountered it as well. Could you please give me a hand?
Thank you!
I’ve just changed the CSS value for
element.stylefromdisplay:blocktodisplay:inlineand the page looks fine again – except for the gallery: it seems to hide behind the black box.I haven’t got the time and I’m sorry that I can’t have a detailed look at your theme but I hope that you’ll figure out how to display the gallery above the black box; try adjusting the
z-indexfor themyGalleryCSS element or change thebackgroundcolor to transparent, some of this might work.Warning: Invalid argument supplied for foreach() in /home/tracyhar/public_html/wp-content/plugins/smoothgallery/utils.php on line 169
Warning: Invalid argument supplied for foreach() in /home/tracyhar/public_html/wp-content/plugins/smoothgallery/utils.php on line 169
Didn’t see this in the FAQ… hope you can help.
Thanks, tracy
can you tell me what exactly you did to produce this error?
You placed the widget in a sidebar, inserted the id of the post/page with the appropriate images on the edit screen of the widget, adjusted the value for
imgsizeand checked that WordPress generated thumbnails in that size? What else did you probably do?Sorry that there’s not much documentation for this right now, but I’m really looking forward to improve this.
is there a particular place the widget needs to be? I tried using the ID for my current front page. It doesn’t work though.
any more research on these widgets?
Thanks!
Any sidebar with enough space for the images will work.
The widget uses the images attached to a post/page with an ID that you can enter in the options of the widget. If there’re no images attached to the given post/page the widget might break apart with a short error message or just don’t display anything. So in your case make sure that you uploaded some images to your front page.
As soon as I find the time I’ll improve the documentation on this one.
I’ve been trying to get the carousel to show with no luck.
All the other options work – I’ve tried ’showCarousel’ and ‘c’ as well – what am I missing?
here’s what I’ve got…
Thanks
a
I “zoxengen” I’m using the theme, but a kind of theme in the show’s homepage spaces and I would be happy if you could not help ..
I just upgraded the plugin and now the gallery isn’t working. It’s showing two static images on the main page. Is there a fix for this?
Ha, nevermind, figured it out. The
config.phpgot overwritten. Thanks!I really love your plugin. It makes it easy for me to create a slideshow for my current posts on wordpress. However I also like this theme – http://bustatheme.com/wordpress/coda-blue/. I’m having a hard time to make them work toegether. I thought iframe was the answer but it does not seem to work. Can you help me on this? Thanks.
have you already installed this theme on your site? Can I have a look at the not-so-well-working galleries? URL?
I have spent 3 hours trying all the different methods to get this plugin to work. I want it to show up only on my homepage. Can you check the site and help me?
I found SmoothGallery and was impressed – but was confused on the implementation. So I was very happy to find your plugin!
I have followed the instructions to install to my main index template. I do see the outline where the gallery should be and I even see the left/right arrows. However, the images are not there. I am only seeing the black status bar like it is trying to find the images. When the plugin is turned off, I am able to see the images.
I have a feeling I missed something really simple…what does it mean when you only see the black status bar?
Thank you so much!
Either the links to the images are broken or another incompatible framework (jQuery, PrototypeJS) might interfere with SmoothGallery.
I’ll write you an email so we can figure this out.
Thanks – plugin is great. Really like it.
you’ve got PrototypeJS on your website which is incompatible with SmoothGallery. To work around this you’ll have to put SmoothGallery inside an iFrame. Have your read my advice on adding another sidebar? Do this, use the widget and you’re all set.
I am attempting to use the smoothgallery widget on a wordpress based site I am building.
I am getting this error.
Fatal error
: Call to a member function register() on a non-object in
/homepages/45/d204742291/…P/wp-includes/widgets.php
on line
427
The website I am building is in the Website section of the form. I would appreciate it if you took a look!
Thanks
Leave a Comment