Jump to content
DV-JF

Editor permissions & active / default language | Searching for best approach

Recommended Posts

Hey girls and guys,

I'll want to open this thread in order to discuss a main problem I've run into with following setup:
 

I'm maintaining a site where different URLs are directed to the same folder. In site/ready.php the $user->language is set based on the $config->httpHost

<?php /* Set language based on the domain and user is not logged in */  

/* Slovenian */   
if(
    $config->httpHost == "www.domain.si" || 
    $config->httpHost == "domain.si" || 
    $config->httpHost == "domain.si.local") {
    if (!($user->isSuperuser()))	$user->language = $languages->get('si');
}
    
/* German */
elseif(
    $config->httpHost == "www.domain.at" || 
    $config->httpHost == "domain.at" || 
    $config->httpHost == "domain.at.local" ||
    $config->httpHost == "domain.ch" || 
    $config->httpHost == "www.domain.ch" || 
    $config->httpHost == "domain.de" || 
    $config->httpHost == "www.domain.de") {
    if (!($user->isSuperuser())) $user->language = $languages->get('default');
}

/* Croatian */
elseif(
    $config->httpHost == "www.domain.hr" || 
    $config->httpHost == "domain.hr" ||
    $config->httpHost == "domain.hr.local") {
    if (!($user->isSuperuser())) $user->language = $languages->get('hr');
}

/* English */
elseif(
    $config->httpHost == "www.domain.eu" || 
    $config->httpHost == "domain.eu" ||
    $config->httpHost == "domain.eu.local") {
    if (!($user->isSuperuser())) $user->language = $languages->get('en');
}

/* Italian */
elseif(
    $config->httpHost == "www.domain.it" || 
    $config->httpHost == "domain.it" || 
    $config->httpHost == "domain.it.local") {
    if (!($user->isSuperuser())) $user->language = $languages->get('it');
}

The homepage (id=1) has following settings:

1163626795_2019-10-2513_15_32.thumb.jpg.bb13dfb04ef00a5c497e2df66e9328d7.jpg

As you can see German (Deutsch) is set as default language. Everything is working nice and fine and I'm really happy with this kind of setup but now there are some new requirements, which causes me quite a headache :

  1. I've to add some pages only in one or two languages (they should not be present in German)
  2. I've to create some editor roles that are allowed to only edit (can be done with https://processwire.com/docs/user-access/permissions/#multi-language-page-edit-permissions) & add pages to their specific language.

What I've found out so far:

  1. The default language can't be disabled and must always be present (though this would be in my eyes the easiest solution)
  2. Creating my own "language select field" - example here: won't work in this case because I've to rely on the native languages in order to setup the right permissions for editors.
  3. There seems to be some solutionsbut I think these won't match for me because I've to think about handling editors and permissions, too.

After searching and searching, scratching my head and searching and searching again, the only possibility that comes to my mind is to add another language for German and assign this language to the specific URL's instead of the default language.

The advantages with this solution for me:

  • I could activate or deactivate any language on any page
  • Editors which are allowed to add pages can get the permission page-edit-lang-default without affecting the German pages.

The disadvantages:

  • All multi-language-fields will have an empty tab for the default language - this may irritate editors a lot
  • Seems to me like a lot of work to do because I've to copy the language field nearly for 1000 pages/repeaters (maybe I'll find an SQL query)

My questions:

  1. How would you handle this task?
  2. Could my setup be optimized in a completely different way?
  3. If I go for my solution (adding another language for German) would it be possible to hide the language tab for default language in any way? 

If some points aren't clear enough please don't hesitate to ask.

Many greets...

Share this post


Link to post
Share on other sites

Push...

No, ideas?

@ryan may I asked you, if you could have a look on this thread and give me a little hint 🙂?

Many greets! 

 

Share this post


Link to post
Share on other sites
On 10/25/2019 at 4:28 PM, DV-JF said:

The disadvantages:

  • All multi-language-fields will have an empty tab for the default language - this may irritate editors a lot
  • Seems to me like a lot of work to do because I've to copy the language field nearly for 1000 pages/repeaters (maybe I'll find an SQL query)

There's certainly a lot to be considered, and quite possibly I haven't thought about all pros and cons, but...

If you have the multi-language settings* "what should happen when alternate language is empty (not translated)?" -> show default language content, then the authors would still only edit the original german default tab, and simply leave the 2nd "fake" german language version alone (just make sure it's activated).

re: "don't confuse authors"
You can simply hide the 2nd german language tab via custom admin CSS or/and hooks. That way, the default tab is still the relevant one for german and is only empty if this page is really meant to not exist in german. Only potential caveat I can think of: required fields. afaik you can't say field X is only required in one language and not in another. At least not out of the box.

You'd probably have to adjust search, and navigations (don't show double entries, always rule out default, etc.)

* this is defined at field-level, and afaik is the default option

Share this post


Link to post
Share on other sites

I'm no expert in multilanguage, done exactly one site, so I can't give any advice. But my primary site is dual language, slovene primary, english being the second, and all that belongs to english language is under /en/ in my page structure. I have different structure, menu, pages, assets etc. Why I did it that way? Because you have all the freedom (or at least I believed so 3-4 years back when I made the site). I guess this is not a path you could take now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By snck
      Hey there,
      for a client website I need to implement a "reviewer" role. "Reviewers" should be able to review new (unpublished) articles to give feedback to editors, but not have the permission to change them. 
      I built a new "reviewer" role that only has page-view permissions for the respective templates, but this permission does not include viewing unpublished pages. How can I grant them access to the unpublished articles without giving them page-edit permission?
      Cheers,
      Flo
    • By Nils Wiere
      Hello, I’d like to give a non-superuser the possibility to add new languages and thought this is done via the lang-edit permission. However, assigning this permission to the role didn’t do the trick. There’s still no option to create a new language under Setup > Languages.
      Do you have any idea on how to provide the permission to add new languages?
    • By flydev 👊🏻
      Hello,
      I would like to present you a new module which aim to facilitate the productivity of your editors/publishers when working on ProcessWire.
      The idea begun when my co-worker told me that when typing in ProcessWire CkEditor field he was feeling "loosing motivation" when writing big wall of text and/or inspiration. So he opened his web-browser and show me a site looking to Wordpress - feel free to put your preferred emoji here - then he opened Gutenberg... typed some text and moving some "blocks".
      I understood immediately why he got this feeling with CkEditor. If you or your client feel like this guy, then you will love this module !
       
      What is currently supported ?
      Features
      Auto-save Medias upload support HannaCode support Blocks Implemented
      Heading Image Paragraph Embed Quote Code Link Table (beta) Block Delimiter Raw HTML Note (custom block markup) Feature Request
      Frontend Edition   
      And there you go for the preview - sorry I am to lazy and bad at typing text so I had a copy/pasta moment :
       

       
      Module featured in the ProcessWire Weekly #317 - Thanks @teppo
    • By horst
      Change Default Language to be None-English | Walk Trough
      When you start a new (single) language site and the default language shouldn't be English, you can change it this way:
      Go to the modules core section:

       
      Select the Language ones by the filter function:

       
      We have four language related modules here, but for a single language site in none english,
      we only need the base module, named "Languages Support". So go on and install it.

       
      After that, you can leave it, ... 

       
      ... and switch to the newly created Language section under SETUP:

       
      Select the default language

       
      Enter your new language name or its Shortcut and save the page.
      I will use DE for a single language site in german here as example:

       
      Now I go to the ProcessWire online modules directory, down to the subsection for language packs and select
      and download my desired (german) one: 

       

       

       

       
      After downloading a lang pack as ZIP, I go back into my SETUP > LANGUAGES > default language page in admin,
      select the downloaded lang pack ZIP and install it:

       

       

       
       
      After the ZIP is uploaded, the files are extracted and installed, most of my screen is already in
      the new default language. To get all fully switched, we save and leave that page, ...

       
      ... and completely logout from the admin.

       
      Now, of course, we directly login back, ...

      ... and see, that now also the cached parts of the admin have switched to the new default language. 🙂

       
      That was it for a single language site in none english.
       
      If you want to have a multi language site, just add more languages to the SETUP > LANGUAGES section.
      When using a multi language site, I think you also want to use multi language input fields, and maybe different page names for your language page pendents. If so, you need to go into MODULES > CORE > filter LANGUAGE and install what you need or want to use of it, (if not already done).
      Thanks for reading and happy coding, 🙂
       
    • By Lmwt
      Hi there,
      using the multi-language site-profile, yesterday I moved all my files into a directory so that the home page is not displayed on my domain url, then I moved them back to the root directory. Maybe I made a mistake while moving the files, but since then I got a "403" error message:
      "Forbidden You don't have permission to access this resource."
      and  these new files appeared in FileZilla as shown on the picture : .xsessions.error, etc.
      The browser show the connection as "not secure" even after clearing the browser data.
      Help!
      Thanks in advance

×
×
  • Create New...