Forum

Thread tagged as: Question

Multi language category sets

Hi,

I'm working on a multi language website, I currently have two collections called:

  1. Solutions EN
  2. Solutions DE

I'm trying to reduce the number of templates I need, by passing in a language variable called $lang

Instead of doing this:

perch_collection('Solutions EN', [
    'template' => solutions_en.html', 
]);

perch_collection('Solutions DE', [
    'template' => solutions_de.html', 
]);

I'm doing this:

perch_collection('Solutions ' .$lang, [
            'template' => solutions.html', 
            ]);

This means I can have one detail template solutions.html instead of two, and possibly more, if more languages are added at a later date.

Question

However, I've hit a bump with this approach.

I need the detail template to use a language specific category set, so the slugs are in the correct language.

Inside solutions.html I have this:

<perch:categories id="solutions_en" set="solutions-en">
<perch:categories id="solutions_de" set="solutions-de">

Both collections use the same solutions.html template.

But, this means the user sees both category sets regardless of what solution collection they're editing.

Is there a way to hide a category set in a detail template based on the current collection?

So, If the user was editing the Solutions EN collection, they wouldn't see the Solutions DE category set.

Or is the recommended approach to use a unique detail template per collection?


Summary

Perch Runway: 3.1.1, PHP: 7.1.12, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1)
App runtimes: <?php $apps_list = [ ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/stephen/Repositories/project/cms/perch
PERCH_CORE: /Users/stephen/Repositories/project/cms/perch/core
PERCH_RESFILEPATH: /Users/stephen/Repositories/project/cms/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/stephen/Repositories/project/cms
HTTP_HOST: project.local
Stephen Meehan

Stephen Meehan 4 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there a way to hide a category set in a detail template based on the current collection?

No, there's not.

Or is the recommended approach to use a unique detail template per collection?

I've never built a multilingual site like this, so there's no recommended approach per se.