Embedding a G2 page into an already-existing site -- can it be done?
|
zgillat
![]()
Joined: 2008-05-01
Posts: 4 |
Posted: Thu, 2008-05-01 06:21
|
|
Hi, I'd like to help a customer embed a G2 instance, into their own, existing, web site. Something like an iFrame, or similar. Their users will stay on their site, the site will maintain their existing nav bar, but there will be a page that has a container, and that container will show a G2 page with images/thumbs. Doable? Looking forward to your reply -- |
|
| Login or register to post comments |


Posts: 616
Yes, very do-able.
Investigate the use of Gallery2 in embedded mode (not so much a 'mode' of gallery as a 'mode' of including the right bits of php in the page to get gallery contents to render.
If I remember right the essence is that on any page that has Gallery contents you need to:
1. make a few prepartory decalarations then initialise Gallery with a call to
2. allow Gallery to prepare content based on the url with
3. When you're rendering your page header there's a call to allow Gallery to output javascript and its own css:
list($title, $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']); foreach ($css as $item) { echo $item . "\n"; } foreach ($javascript as $item) { echo $item . "\n"; }and 4. When you're rendering the html of your page you include this to spew out the html that gallery prepared for you in step 2:
You don't need an iFrame, the gallery html is just a regular part of your page.
You can put the Gallery contents anywhere you like in your page; you'll need to adjust your theme and css to get it to 'look' right.
Links within Gallery are handled automatically by repeating the page url and adding Gallery's parameters to the end - so your website loads the same page, runs through the same procedure and Gallery prepares the new content based on the header/form contents at step 2 which then gets displayed in step 4.
That's the bare bones, there should be more information in the codex.
Posts: 4
You're awesome. THANK YOU for the quick and thorough response.
Truly appreciated ---
Ziv.
Posts: 2
Hello alecmyers,
Should the external web site hosted on the same server as g2?
So the question is - if I have the site hosted on Server 1, and have gallery2 installation on Server 2. Can I embed visually g2 albums to my site?
As I understand we can't do that ...
Thanks in advance.
-----------------
Slava Moskalenko
Posts: 616
No, you can't do that with Gallery2 running in its "embedded" method. The standard embedding method builds both the embedding and embedded (gallery) pages with one single php process.
You could try to bodge something where the embedding page calls the remote Gallery server, caches the html then feeds it back out again to the browser - but I wouldn't have a handle either on how difficult it would be or what the performance would be like. Some AJAX calls (unrelated to Gallery) work like that I think, but I'm no expert.