Override template on url?
|
garyamort
Joined: 2007-01-28
Posts: 14 |
Posted: Fri, 2007-08-03 14:09
|
|
Can I specify a different template to be used to display a gallery albumn or site on the url? Something like &theme=matrix to force the matrix theme to be used? |
|
| Login or register to post comments |

Posts: 32506
no, but you can easily hack your g2 to do that.
that's what http://themes.gallery2.hu/ is doing.
code to change is at modules/core/classes/GalleryView.class function loadThemeForItem().
there, you can add 1, 2 lines to check if request includes a GET/POST param specifying the theme, e.g. with $themeId = GalleryUtilities::getRequestVariables('theme');
then you can add &g2_theme=matrix to any URL and it should be used appropriately.
the modification at http://themes.gallery2.hu/ stores the preference in the user's session such that the same theme is used for subsequent requests without changing other stuff (no need to trick g2 to add the new parameter to all URLs).
e.g. with
global $gallery;
$session =& $gallery->getSession();
$session->put('theme', $themeId);
so the overall code could look like:
global $gallery; $session =& $gallery->getSession(); $themeId = GalleryUtilities::getRequestVariables('theme') if (!empty($themeId)) { $session->put('theme', $themeId); } else { $themeId = $session->get('theme'); } if (!empty($themeId)) { // use existing code to get the theme for the item / default the theme }--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 14
Thanks...I'm hopefull with this last item they will actually start using the gallery and post it up on the frontpage so then I can post a link to it for everyone here to enjoy.
Not really using much in the way of "advanced" features.
It's just a photo gallery for a hair salon...Menalto Gallery didn't really fit into the theme, and trying to get it to embed just left me frustrated.
So what I'm mainly doing is setting up 2 themes, one for the "admin" use and one for the mebedding(the lightbox template works well for embedding, sliced down a lot of functionality from it so all it does is display the thumbnails and give people a way of viewing them in a lightbox)
Posts: 3
I'm trying to get this to work, but I am very new to gallery, not so new to php. I've tried adding the above code to the GalleryView.class loadThemeForItem function. After many attempts all I can get it to do is render a blank page.
Can anyone help?
Gallery version = 2.2.4 core 1.2.0.6
PHP version = 4.4.4 cgi-fcgi
Webserver = Microsoft-IIS/6.0
Database = mysqlt 4.1.22-log, lock.system=database
Toolkits = Gd, SquareThumb
Acceleration = none, none
Operating system = Windows NT THUNDER 5.2 build 3790
Default theme = my_siriux
gettext = disabled
Locale = en_US
Browser = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)
Rows in GalleryAccessMap table = 25
Rows in GalleryAccessSubscriberMap table = 85
Rows in GalleryUser table = 5
Rows in GalleryItem table = 83
Rows in GalleryAlbumItem table = 13
Rows in GalleryCacheMap table = 0
Posts: 32506
there's a new event available in g2.3 to allow this kind of feature.
see:
http://codex.gallery2.org/Gallery2:Theme_Override_By_Event
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage