Jump to content

LanguageFieldTabs


adamspruijt

Recommended Posts

One idea came up, and was just curious about the feasibility of it: What if the "active" tab was based on the current user's language? So if I had my language set as Spanish, I'd see the Spanish tabs active (rather than default language tab) when editing a page? 

Thanks for suggesting this Ryan. I remember pondering the idea early on but dropped it at the time to avoid getting my self overwhelmed with ideas, I sometime spend too much time thinking of the millions of thing I *could* do instead of just doing any of them. I add it ASAP.

Link to comment
Share on other sites

I've been putting some thought into it here, and am thinking we need a config.user.language variable added to PW's JS config variable. I don't yet see another way for LanguageFieldTabs to identify the current user's language. Let me know if this sounds like what you'd need, or if you had another idea? 

Also, I just submitted a PR to you that makes the empty vs. populate state of LanguageFieldTabs work with CKEditor inline mode, and also makes makes that state a little more more useful for the page name (2.3.2+/dev branch). 

  • Like 2
Link to comment
Share on other sites

I've been putting some thought into it here, and am thinking we need a config.user.language variable added to PW's JS config variable. I don't yet see another way for LanguageFieldTabs to identify the current user's language. Let me know if this sounds like what you'd need, or if you had another idea? 

Also, I just submitted a PR to you that makes the empty vs. populate state of LanguageFieldTabs work with CKEditor inline mode, and also makes makes that state a little more more useful for the page name (2.3.2+/dev branch). 

That sounds like what I'll need for sure Ryan. I was going to try and get around this but I think the best solution is to have the default tab selected in version of PW that offer the "config.user.language variable" and otherwise maintain the current behavior.

  • Like 1
Link to comment
Share on other sites

That sounds like what I'll need for sure Ryan. I was going to try and get around this but I think the best solution is to have the default tab selected in version of PW that offer the "config.user.language variable" and otherwise maintain the current behavior.

I took a closer look at this and realized we'd need to set that config.user variable in the admin theme, and that it'd be better not to have an admin theme dependency for this module. So what I did instead is updated your module to pass along the active tab index in it's JS settings (config.LanguageFieldTabs.activeTab). It determines the active tab based on: if a GET variable is present called "language", containing the ID of a language, it uses that. Otherwise it uses the current user's language. This way you can have it focus on the right language tabs when a user clicks "edit" from the Spanish version of a page, for example. Here is what my edit link looks like on the front end:

echo "<a href='{$config->urls->admin}page/edit/?id=$page->id&language=$user->language'>Edit this page</a>";

If there is no "language" GET variable specified, then it just defaults to the current user's language, whatever that may be.

The end result is that the tabs always focus on the right language. In testing here so far, it seems to work quite nicely. I just sent over a pull request for this update.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I figured this doesn't trigger when using good old Fredi. :)

The nice thing it would be simple to add support cause of modulotastic PW

if($this->modules->isInstalled("FrediProcess")) {
   $this->addHookAfter('FrediProcess::execute', $this, 'loadTabs');
}

Shall I make a PR or would you consider adding it?

Thanks

  • Like 1
Link to comment
Share on other sites

Do you guys think it makes sense to bring LanguageFieldTabs into the core? So far I haven't come across a multi-language site install where I wouldn't want it, so starting to wish it was just there by default. 

  • Like 6
Link to comment
Share on other sites

Do you guys think it makes sense to bring LanguageFieldTabs into the core? So far I haven't come across a multi-language site install where I wouldn't want it, so starting to wish it was just there by default. 

Only if you take HelperFieldLinks, FormSaveReminder, PageEditSoftLock too ;)

@adamspirit I'll make a pullrequest to add support for Fredi.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Just noticed that if you uninstall language support, it doesn't also uninstall "Languages Support - Tabs". It gives a couple of php warnings/notices from the tabs module file. BTW, I am talking about the latest PW dev version where this is now a core module.

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Hello guys, my name is David and i´m new here.
Processwire is
great CMS but i have a problem with the LanguageFieldTabs. The are not displayed.
How should I install the tabs exactly?

Does anyone have a step by step guide?

I have followed these instructions:

  1. Place the .module file in your /site/modules/ directory. If the
    module contains more than one file (like supporting .css or .js files
    for example), it should be created in it's own directory under
    /site/modules/ with the same name as the module. For instance, the
    AdminBar module and supporting files should be placed in
    /site/modules/AdminBar/.
  2. Login to your ProcessWire admin and click on the Modules tab. Click the check for new modules button. Click the install button next to any of the new modules that you want to install.

unfortunately there is no further description.

Best Regards

David

Link to comment
Share on other sites

David,

Welcome to PW and the forums. This module is now part of the core so you don't need to install it this way. If you are using PW 2.4 (i.e. the latest version) you should see it under the "Core" tab under /modules/. I believe its called "Languages Support - Tabs" (see category Language)

Edited by kongondo
  • Like 3
Link to comment
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
×
×
  • Create New...