====== Adding Shadowbox to Magento ====== Here is a tutorial on how to add the [[http://mjijackson.com/shadowbox/#demos|Shadowbox]] modal box to your Magento powered online store. Magento Wiki offers the help of [[http://www.magentocommerce.com/wiki/adding_lightbox_to_magento_v2|adding Lightbox2 to your Magento]] install, for those not interested in the Shadowbox Modal. ==== Step 01 - Upload Shadowbox ==== [[http://mjijackson.com/shadowbox/#download|Download Shadowbox]]. Go with the second download option. Just the files necessary to run shadowbox. Assuming that magento is installed in your root directory (yourdomain.com) - From the root open the /js directory yourdomain.com/js Inside of the /js directory create a new directory named "sb" which is short for shadowbox yourdomain.com/js/sb Inside of /sb lets upload the 3 shadowbox directories /build, /images, and /src. So now on the server we should have: yourdomain.com/js/sb/build yourdomain.com/js/sb/images yourdomain.com/js/sb/src ==== Step 02 ==== Lets open your template directory and drop in the CSS file that comes with Shadowbox. This tutorial will make use of the default template. So if you are not using the default template, you'll need to exchange the default template name for your own template directory name. The default template can be found here: yourdomain.com/skin/frontend/default/default/ So now, you should have the CSS file named shadowbox.css in this directory: yourdomain.com/skin/frontend/default/default/css/shadowbox.css The Shadowbox CSS file can be found in /build/css/ of the shadowbox zip file that you downloaded. ==== Step 03 ==== Lets open your template directory and drop in the images used by Shadowbox. Open your default template, open the images directory, and create a new directory named "sb". Drop in the images that are found in the images directory of the Shadowbox download. So now you should have yourdomain.com/skin/frontend/default/default/images/sb/loading.gif yourdomain.com/skin/frontend/default/default/images/sb/loading-light.gif yourdomain.com/skin/frontend/default/default/images/sb/overlay-85.png ==== Step 04 ==== Now we need to modify the Shadowbox Javascript. Open up the javascript found at: yourdomain.com/js/sb/shadowbox.js Around line 81, lets replace loadingImage: 'images/loading.gif', with loadingImage: SKIN_URL + 'images/sb/loading.gif', And around line 131 lets replace overlayBgImage: 'images/sb/overlay-85.png', with overlayBgImage: SKIN_URL + 'images/sb/overlay-85.png', ==== Step 05 ==== Now lets modify the Magento template files and set them to use Shadowbox. Open up yourdomain.com/app/design/frontend/default/default/layout/page.xml Around line 42, look for And insert this after Scroll down around line 49 and look for css/menu.css After that, insert this: css/shadowbox.css Save and close. Now lets open up yourdomain.com/app/design/frontend/default/default/template/catalog/product/view/media.phtml Around line 51 find this code: getGalleryImages() as $_image): ?>
  • And replace it with this: getGalleryImages() as $_image): ?>
  • This just adds the rel="shadowbox[rotation]" call to the anchor tag, to let shadowbox know that we are summoning its powers. Save and close. Now lets open the file yourdomain.com/app/design/frontend/default/default/template/page/html/head.phtml Lets replace With this Save and close. ==== Enjoy The Fruits ==== And now shadowbox should be fully functional for your product images. If you run into any problems, feel free to post questions or comments [[http://c.hadcoleman.com/2008/06/adding-shadowbox-to-magento-ecommerce|at my place]].