Zone for an album in the galleries

Post

Posted
Rating:
#4894 (In Topic #1082)
Avatar
Standard member
RailDude64 is in the usergroup ‘Fan in training’
Greetings fellow Composr-ites,
I have tried modifying the proven examples for creating zones but I have not been able to produce any magic for my goal other than changing the overall theme for the site.  I would like to be able to apply a theme to a specific album or group of albums within the Galleries.

Thanks in Advance for your assistance.

So I have been told that I did not explain my goal very well.

My goal is to be able to change the theme that is being displayed based on an album (or group of albums that are based on the same subject matter),  For example, the museum that the site is for, is working to restore a steam locomotive, so I would like theme to show a site background image of the locomotive.  We also have a railroad passenger car (British - railway carriage) that we are also restoring, so naturally, we would want the theme to show a site background image of the passenger car.

So my question is "How do you create a zone with a hook to an album in a gallery?"

Please let me know if I still have some more explaining to do.

Last edit: by RailDude64


RailDude64
IT and $ guy for
San Antonio Railroad Heritage Museum SARHM.org
Using Composr on InMotionHosting.com
Composr: 10.0.26
Linux: 2.6.32-954.3.5.lve1.4.64.el6.x86_64
PHP: 5.6.39
MySQL: 10.2.12-MariaDB-log 
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#4943
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Alright, I have good news and bad news.

The bad news: themes are pretty much zone-specific. Because the 'galleries' module within Composr is located within the same zone as the rest of your site (depending on if you have a single public zone or if modules are within the SITE zone), it must share the same theme with everything else in that zone.

For example, let's assume you have a "single public zone" -enabled website. The Gallery, Downloads, Chat, etc, (including the Comcode pages within that base zone), all must use the same theme. The only way to bypass this is to move the galleries module from your main zone into its own zone, but the entire gallery system (all galleries, regardless of album) would share the same theme and background image. Plus, I don't know if moving modules like that would cause problems elsewhere, so I really wouldn't recommend doing that.

That being said (which leads me to the good news; give me a drumroll please):

There are a few template-based hacks you can make!! The album wouldn't have its own theme though, but at least you can achieve changing the background image depending on what album a user is viewing.

I've personally tested this so it does work. However, you should proceed at your own risk if you're not comfortable with editing template files. Also, you must have the catalogues module installed (installed by default unless you specifically chose to remove it during installation). Keep in mind I have written this tutorial as if you have no knowledge of navigating through or editing files within Composr. This is not to be rude, rather it is only to accommodate your skill level which is unknown to me. :)

  • Step 1: Add a custom catalogue entry to your gallery
    • AdminZone -> Content -> Galleries -> "Choose custom Gallery fields"
    • Under "New field 1", let's add some basic info:
      • Name: Background Image
      • Type: A brief line of text (no Comcode support)
      • Order: 1
      • Visible: No (make sure checkbox is UNTICKED)
    • Click 'Save'
  • Step 2: Edit the GALLERY_FLOW_MODE_SCREEN template file:
    • AdminZone -> Style -> Themes -> (choose your theme) -> "Edit templates"
    • Under "Existing" (should already be selected), scroll down, find GALLERY_FLOW_MODE_SCREEN, click on it, hit "Edit" just below that.
    • Add the following to the first line of this template, before all the existing stuff:

Code

{$SET,album_bg,{$CATALOGUE_ENTRY_FIELD_VALUE,{$CATALOGUE_ENTRY_FOR,gallery,{CAT}},0}}
  • (continuing from step 2 above):
    • Scroll to bottom and click "Save" (or "Save and stay", doesn't really matter)
  • Step 3: Edit the GLOBAL_HTML_WRAP template file:
    • Repeat step 2 above to navigate to this template.
    • Once open, locate your <body> tag. You will need to add the following code DIRECTLY AFTER <body (no space):

Code

{+START,IF,{$IS_NON_EMPTY,{$GET,album_bg}}} style="background-image: url('{$BASE_URL*}/themes/{$THEME*}/images_custom/{$GET,album_bg}') !important;"{+END}

So, it should look something like below. Yours may look slightly different than mine which is fine, just as long as you entered the code above right after <body (no space):
NOTE: Composr is auto-changing the body tag below to span. Rest assured, it's meant to say body.

Code

<span{+START,IF,{$IS_NON_EMPTY,{$GET,album_bg}}} style="background-image: url('{$BASE_URL*}/themes/{$THEME*}/images_custom/{$GET,album_bg}') !important;"{+END} class="website_body zone_running_{$ZONE*} page_running_{$PAGE*}" id="main_website" itemscope="itemscope" itemtype="http://schema.org/WebPage">

  • Step 4: Lastly, we just have to define our image within the gallery
    • AdminZone - > Content -> Galleries -> Add/Edit Gallery
    • Scroll down the page, you should see a new field called Background Image (this is what we named it during step 1).
    • Just enter the filename, including the file extension, of your image. The URL is hardcoded into the template edits we just did so we don't have to enter that. (example – Background Image: filename.jpg)
    • Make sure you uploaded the image inside your /themes/(yourtheme)/images_custom/ folder.
    • Click "Save"

You should now see your normal background image throughout the site, except when you navigate to your gallery album, it should change to the image we set in our custom field. If it doesn't, try clearing your caches (instructions below).


You can add a custom background image for each gallery you create. Just enter the correct filename under the custom field we created for each gallery and ensure you upload it to the /images_custom/ directory of your current theme. If you leave a field blank for an album, your regular background image will just display normally.

I hope this works for you, reply back if not and I will troubleshoot.


To clear Composr's caches:
  • Navigate to the upgrader.php file within your browser.
    • (i.e.: www.mysite.com/upgrader.php)
  • Enter your password and login, click "clear caches".
Online now: No Back to the top

Post

Posted
Rating:
#4944
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Actually it is possible to have different themes on different galleries, but it requires an expert level of Composr skill.

You can use the 'Redirects' feature to have a module running in multiple zones. Then you make sure you always link to a gallery through the zone you want to run it in.

Then you have to worry about making each gallery start it's own breadcrumb trail (to stop you back-navigating to a different gallery that is not supposed to be in the zone you're in). This is possible via the breadcrumbs override feature, you need to code up some fiddly XML for that.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Salman, John Connor, Vaiva, ManojSree

Forum statistics:
  • 1,084 topics, 5,240 posts, 6,124 members
  • Our newest member is aquantindia
Birthdays:
Back to Top