How I integrated the slider theme into my website underwa.ter.net
corbosman
Joined: 2005-10-06
Posts: 30 |
Posted: Thu, 2006-11-09 11:04 |
I've been asked many times how I made my site look the way it does. Gallery blends in well into my site http://underwa.ter.net, even though im using a theme that doesn't lend itself to this kind of integration at all. But it was the theme that I liked, so I went about to modify it to my needs. I think that if you truly want to make gallery an integral part of your website design, some form of modification is almost always necessary. Here are some of my thoughts on how I went about to do this integration. First of all, before you start any work, you should make a plan of your website design. What layout do you want to use? How do you navigate through your site? What colors would you like to use? I wanted a very simple design, devoid of clutter, as to not distract from the images. I chose to use a top navigation bar that divided my site into a few main sections; Portfolios, Travel reports and news, and About. Do this before you even think about how to integrate gallery. I believe you should adapt gallery to your design, not the other way around. I built my site using Dreamweaver, except for the PHP parts and the galleries ofcourse. Dreamweaver worked very well for me in developing the design, especially because it handles CSS extremely well. Dreamweaver allows me to create templates for certain parts like the navigation bar, so if I change something it gets changed throughout the site (except for gallery, as I will explain in a bit). Personally I would try to use some form of software that can do this, as it makes maintenance so much easier. Now that I had my design, I went about looking at gallery. I liked the slider theme, so I wanted to use it as a bases for my image displays. When you use gallery out-of-the-box, it becomes a standalone webpage with its own look and feel. You can pick a theme and colorpack, but it still looks the way it does. This is often not how your website looks so I started to read the forums on how to modify gallery as to blend in better with my own site. Gallery has quite a bit of information about embedding and integrating. Here are some links I used:
Since I wasn't using an existing CMS, I figured I could use the 'editing theme templates' method of integrating gallery. Basically you change the templates that the theme provides to fit your own design. That's what makes gallery such a wonderful tool, it allows you to seperate functionality from design. Gallery has a great method to change the templates. Just go to the 'slider' theme directory, and create a directory 'local' in whatever directory the file you want to change exists in. I started by editing theme.tpl so I created a directory 'local' inside the 'templates' directory and copied 'theme.tpl' to that directory. Now I started to edit this template to have a navigation bar. This meant adding some HTML near the top of the templates. You can find the resulting file here. Look for comments marked by the string "COR". Unfortunately, this didnt show me a navbar! Whats going on. Maybe I needed to reload the templates. This is something you always have to do when editing templates. Go the the Site Admin link, go to Maintenance, and find the template cache deletion link. Use it often. It didnt fix my problem though. I looked at the source, and saw that the navbar was actually there. So why didnt I see it? I looked a bit closer at the slider theme and noticed it uses absolute positioning. Basically it put the image on top of my navbar making it invisible. Ok, thats not good. Im not going to explain CSS or HTML. Buy a book I figured I had to change the css to fix this absolute positioning problem. So, I made a directory 'local' in the same directory as theme.css and copied theme.css there. Right at the top of the css file you see the problem. It positions the image area in the top left corner of the screen. Argh. Ok, what if I change it so the top is not at 0 but at 50 px? Ok, that did something. The image area was moved 50 pixels down and I saw my navbar at the top. Before I continue, I need to explain my navbar, because some people might not understand it. If you do what I did sofar, the navbar will look ugly. It's not a horizontal navbar at all, but an ugly list. Im not going to fully explain how to go from a vertical list to a horizontal navbar. Use google. It is styled using CSS, and I copied the style information from my site CSS file to the theme CSS file. You can see the resulting theme.css here. With that CSS file you see my navbar on top, but the rest of the gallery stuff still looks like plain old slider theme. Next I figured id have to change the colors of the slider theme to match my own colors. This again means changing CSS information. I need to change all 'background-color' elements to my own background color. Here's the resulting theme.css. Look for color #282828. This is starting to look good. Things arent quite finished though. First of all I wanted to do some more minor visual changes, but more importantly, there are some layout bugs. In IE (what else is new) the current CSS is not working correctly as the image is now being overlapped by the thumbnail bar, no doubt caused by lowering the image display area 50 pixels. Im also seeing some ugly jumping of the navbar when switching from my own pages to the gallery theme pages. In my own pages I needed to do some CSS tricks to avoid that from happening. It's basically working around CSS implementation differences. I need to add these workarounds to the theme.css file. To fix the overlapping layout in IE, it wasnt enough to change the CSS. The slider theme extensively uses Javascript, and it's in this JS that we have to fix another problem. It computes the size of the image area, and because we lowered the image area 50px, this computation is now wrong. The changed slider.js can be seen here. The changes are around line 186. I also made another minor change to add a permanent scrollbar on the right. This fixes the jumping navbar problem. There may be better fixes for this, but this is what I did. Quote:
if (!getstr && !document.slide) return; Argh, this didnt work. The changed javascript wasnt being executed. I quickly noticed that I also need to change header.tpl in the templates directory. Copy it to the local dir and make it load slider.js from the local dir. Here's my header.tpl. I also had to make another small change in theme.tpl, as it has a line to hide the scrollbar, and I wanted to force the scrollbar to avoid jumping of the screen. You can decide for yourself if you want or need this. I commented out the line: Quote:
{*body.gallery { overflow: hidden; }*} We're still not done. I wanted some more visual changes.. I'll go through them one by one
That concludes all the changes. I also changed some minor things in the theme configuration inside gallery. Specifically, I limited the max size each image could be viewed at by non-administrators. Experiment with it. All the files that I changed can be viewed here. Changes are usually commented, but you may want to do a diff between the original and my version. I may have also forgotten some changes, as Im doing a long time after the actual work. If you have any questions, feel free to send me a message. Remember though, this doc is not meant to fix your own site. It is merely a diary of how I changed my site. It is almost certain that to do this to your own site you'll have to deviate from what im saying here. And I may also not have chosen the right way to do things, I dont know. But it works for me, so im happy. Besides changing the theme I also did some other forms of embedding. You can call gallery functions from within any PHP file which allows you to do interesting tricks outside of gallery itself. My site contains several such additions..
|
|
Posts: 19
Thank you very much for this extensive eplaination! I can certainly work with it, but it is indeed not as easy as it seemed. Thans to you I know where to look for the right places to adapt the Slider layout and finally fit it in my website.
(Trouwens, jullie foto's zijn echt fantastisch!)
Posts: 64
That is very cool mate, and this will get very handy in the future!
(Wat geekess zegt, je fotos zijn echt geweldig! )
Posts: 13451
Very informative, and it would make a great addition to the codex too. Would you mind porting it over for easier reference later? The forums has such a large amount of posts that it makes it hard to find specific information like this later.
h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org
Posts: 30
Sure, no problem. I'll do it right now.
Cor
Posts: 13451
Excellent!
h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org
Posts: 30
It's at this url: http://codex.gallery2.org/index.php/Gallery2:How_I_integrated_the_slider_theme_into_my_website , im not sure what the best place is to link it. I put it in the visual embedding list at http://codex.gallery2.org/index.php/Gallery2:How_Tos
Posts: 19
Converting my site to your style is much more easy than I thought. Your howto is very clear and easy to use. But that's only the barebones and changing it from there is a lot harder. Take for instance the scrollbars. I was planning on forcing vertical thumbs. My albums are arranged by month and each month has a lot of photos. But somehow the new code clips the last thumbs. Probably has something to do with allowing the scrollbars/overflow, but I haven't found it yet (it is not high on my priority-list).
Something else is that I would like to display the description under the picture. Can't get that done. Haven't even found where to start yet. But I'll get there.
Posts: 30
Ive never looked at the vertical thumbs, so im not surprised they're not perfect. The slider theme is really quite a nightmare to adapt because of all the css positioning. Im happy enough I got it working for my own site For the titles, in slider.tpl you see a div called 'thumbs'. In it you can use {$it.title} but you'll have to fiddle with placement of the text. I couldnt get it to work easily, so have fun
Cor
Posts: 19
I guess I'll drop the vertical thumbs and the description instead of title
With the program Bordermaker I can add the iptc-caption to the photo, maybe that's a better solution than to bang my head against a slider-wall.
That leaves me some time and energy to spend on the rest of the website. I'm sorry, it's going to look a lot like yours, because I love the design so much, but I will give you credit for it on the website, don't worry.
Posts: 19
I've run into a little problem with the code you provided, Cor.
Substituting the Image Description for the Image Title works. I don't know how or why, except that I changed $it.title into $it.description, which didn't work yesterday, but does today.
But generating the thumbs like you do for your travelpage doesn't work. I've taken the code above for the thumbs, changed the paths to point to the gallery directory and changed the id for the album. I probably missed something, but I don't know what.
The album select box does work when using the same parameters.
Do you have any suggestions?
Posts: 30
There is a part in that code that checks for the keyword 'visible'. I use it to only show a thumbnail if i make the gallery 'visible'. So either add that keyword to all your albums or remove that piece of code.
Cor
Posts: 19
Silly I didn't see the keyword thing. It's actually quite brilliant, I must say. I will use this code on the yearly/monthly archive page and I can imagine I wouldn't want all albums to show up there...
Again, thank you very much for your adaptation, and for the insight in the workings of gallery code. It is a lot clearer now and maybe, if I find time somewhere, I can use it to merge the Slider layout with the Ajax theme... musing...
Posts: 1
You say:
"Specifically, I limited the max size each image could be viewed at by non-administrators. Experiment with it."
That's seems to be exactly what I'm missing in slider, but I can't find where you do this. Any hints? Thanks in advance.
Posts: 30
You do this with the Permissions interface once you have logged in as an administrator.
Cor
Posts: 1
Just to let you know,
I noticed a typo in the code on the codex page, for the drop down box:
Posts: 23
This is a good guide for getting this accomplished, and I'm glad I found it. I love the slider theme, but almost scrapped it because I couldn't figure out how to integrate it.
Actually, I'm still struggling. I made some changes to the theme template, and to the css file. Mainly, inserting the header nav that I need.
When I drop the imagearea 30 pixels, I got mixed results.
- IE didn't change a lick. Looks like the default install.
- Firefox displays the header nav beautifully, but NO photo appears, at all!
update: I removed the postion:absolute, and was able to see the header in IE, but still no photo in FFox.
update II: After adding a border to the main image, I DO see an empty border in FFox, where the image should be. It's about 2px by 2px,. If you blink, you'll miss it.
How do I fix that? Why would the image not display?
update III: Clicking on the magnifying glass in the lower right corner to display the image full-size, works fine. All images after that work.
FINAL UPDATE: Playing with the CSS fixed it. I now have:
I think using 30 instead of 40 px for the top was the problem. Thanks for all your help, amsweb1. ;)
My gallery is at http://www.heritageoakslandscaping.com/portfolio/main.php
Thanks.
Posts: 2
Thank you for this post. I was ready to give up on Gallery 2, but because of this post, I was able to somewhat get my site up and running. Kindof. .... The main issues that I have right now, is that the nav bar disappears when restoring the window. I can not figure out how to change the color of the font where the title of the picture is displayed...
Is there a way to add say an artist statement to any of these albums? I am thinking not... That said, I have another silly question.... How did you make your own index.php and bypass the main.php? How did you create the Contact.php? Once created, where do they live in the site directories? Did you create your own pages folder and drop them in there? Probably all silly questions.. I am new to coding and web design. I am able to get buy with the help of manual and all of these helpful posts.
Thanks in advance for all of your help