Hello,
I'd like to be able to create one gallery using one theme, and install another multisite G2 install to another directory that will display the same photos as the original gallery, but using a different theme. The impetus for this is that I'd like one gallery install to use the theme I picked out for my embedded gallery, and another to use a more general non-embedded theme (e.g. Classic or Matrix).
Another way of looking at this is that I'd like to mirror a photo gallery's contents with another that has its own settings/appearance.
Is this possible without writing a PHP script to manually shuttle stuff from one database to another at some sort of timed interval?
Posts: 32509
i don't see how this would work easily.
a much easier approach would be to have a switch
if (GalleryUtilities::isEmbedded()) {
}
in your theme.inc showX...Page() functions and dependent on that, load a different template file.
or do the switch in the templates files.
Posts: 28
Thank you for that... I'll give it a try. Do you think there would be enough interest in a patch, so that others can make this same change?
Posts: 32509
when redesigning the architecture of the themes / layouts 3 months ago, we asked us if we wanted this feature: different themes / templates for embedded G2 mode than G2 standalone mode.
we figured this wouldn't be used very much. but yes, for some users it might be interesting.
fact is, we can't offer this feature now. it could be added, but it'd require some changes.
for now, you have to create your own theme that does the isEmbedded() switch.
Posts: 28
And to alter a theme to add the isEmbedded switch, I'd have to hard code in a reference to another theme, right? In other words, the theme would have to be available and installed - no GUI or broader general use tools for making a hack like this applicable to everyone without making an edit to tailor the user's install?
Is my basic assessment right here?
Posts: 32509
well, you could do everything in a single theme.
first start by cloning your prefered theme http://codex.gallery2.org/index.php/Gallery2:Themes .
and then in the showX..Page() functions, do your if isEmbedded thing and if true, use themeembedded.tpl else use themestandalone.tpl etc.
use a themestandalone.css and a themeembedded.css etc etc.
Posts: 28
Cool... could you hook me up with some syntax:
if (!GalleryUtilities::isEmbedded()) {
$template = 'Matrix.tpl';
}
$template was a wild guess at what I need to change. Can you kindly correct this using my example?
Once I have figured this out (with your help), I'll provide documentation for others who wish to do what I'm attempting to do here.
Thanks for your help!
Posts: 28
edited: deleted some other stuff (realized I didn't clone the theme properly)
I guess the main problem is just this:
if (!GalleryUtilities::isEmbedded()) {
$template = 'Matrix.tpl';
}
Posts: 28
I think I got it, never mind:
/* Add our header and styles */
if (GalleryUtilities::isEmbedded()) {
return array(GalleryStatus::success(), 'theme.tpl');
}
else {
return array(GalleryStatus::success(), 'theme2.tpl');
}
where theme2.tpl is the new template
Posts: 28
Okay, it's done and working well... For those who care, here is what I did:
1) cloned the theme I wanted to use using the instructions here
2) replaced each:
return array(GalleryStatus::success(), 'theme.tpl');
in g2dir/themes/theme_name/theme.inc with:
if (GalleryUtilities::isEmbedded()) {
return array(GalleryStatus::success(), 'theme.tpl');
}
else {
return array(GalleryStatus::success(), 'theme_matrix.tpl');
}
also did the same for return array(GalleryStatus::success(), 'error.tpl');
3) inside g2dir/themes/theme_name/templates, I copied over the following desired files from the theme I wanted to revert to for non-embedded galleries:
admin.tpl
album.tpl
error.tpl
module.tpl
theme.tpl
instead of replacing the current files in this directory, I called them:
admin_matrix.tpl
etc... (these names can be arbitrary, but they must follow the naming convention used in step 2, in my case 'xxx_matrix.tpl')
4) edited theme_matrix.tpl, changed the following lines:
{if $theme.pageType == 'album'}
{g->theme include="album.tpl"}
{elseif $theme.pageType == 'photo'}
{g->theme include="photo.tpl"}
{elseif $theme.pageType == 'admin'}
{g->theme include="admin.tpl"}
{elseif $theme.pageType == 'module'}
{g->theme include="module.tpl"}
{elseif $theme.pageType == 'progressbar'}
{g->theme include="progressbar.tpl"}
to:
{if $theme.pageType == 'album'}
{g->theme include="album_matrix.tpl"}
{elseif $theme.pageType == 'photo'}
{g->theme include="photo_matrix.tpl"}
{elseif $theme.pageType == 'admin'}
{g->theme include="admin_matrix.tpl"}
{elseif $theme.pageType == 'module'}
{g->theme include="module_matrix.tpl"}
{elseif $theme.pageType == 'progressbar'}
{g->theme include="progressbar_matrix.tpl"}
5) copied g2dir/themes/theme_name/theme.css belonging to the theme I want to use for non-embedded galleries to my new modded theme, called it theme_matrix.css, again following my same naming convention.
6) edited my theme_matrix.tpl again, this time changing:
<link rel="stylesheet" type="text/css" href="{g->theme url="theme.css"}"/>
to
<link rel="stylesheet" type="text/css" href="{g->theme url="theme_matrix.css"}"/>
7) activated my new modded theme in the relevant galleries, set the usual options through the "edit album" page.
If you try this, please let me know how this goes! Obviously, my example was based around using the Matrix theme. You can make the appropriate substitutions to revert to a theme of your choice.
Posts: 32509
yep, looks exactly like i'd have done it, kudos
maybe change the topic title and then we can add your instructions as a howto to the codex.
something like "How to use different themes for embedded and standalone mode" or so.
you can register on codex.gallery2.org and edit the how to page or i can do it.