adrian Posted November 25, 2016 Posted November 25, 2016 Hi everyone, Here's a new module that lets you control whether multi-language support is enabled at the page / branch level, rather than only per template. http://modules.processwire.com/modules/restrict-multi-language-branch/ https://github.com/adrianbj/RestrictMultiLanguageBranch This is ideal for a site with repeated branches using the same templates where only some need to be multi-language. I think it is confusing to provide multiple language inputs for fields when they are not required - it just bloats the admin interface for site editors. I am hoping to expand this module to allow selection of which languages are supported per page/branch, but I am waiting on @ryan's response to this request: https://github.com/processwire/processwire-requests/issues/54 - to me this would be even more powerful if you have a situation where certain branches need some languages and other branches need different languages. The module config settings shows a summary of the restrictions you have implemented, eg: This shows that we have started with the home page which disables multi-language on itself and all its children/grandchildren (because "This Page Only" is "False". Next we have the /report-cards/ page multi-language enabled, but no inheritance (because "This Page Only" is "True"). The only branch below this to have multi-language enabled is Guanabara Bay and all it's children etc will also be enabled. All other report card branches will be disabled because they will inherit directly from the config settings default status. The Settings tab for each page gives you three options: Inherit, Enabled, Disabled. The screenshots give you an idea of how the Inherit option works and the information it provides based on the status it is inheriting and from where. My goal for this site was to just enable multi-language support for the Guanabara Bay report card branch of the tree, as well as the home page and the /report-cards/ parent. All other branches have multi-language support disabled which makes content entry much cleaner. Hope you guys find a good use for it and I'll be sure to update with the ability to define which languages are available on which pages/branches if Ryan comes up with a core solution for changing the returned $languages. Please let me know if you have any problems / suggestions. 19
adrian Posted November 25, 2016 Author Posted November 25, 2016 Hi everyone, @Christophe was kind enough to notice that I had mis-spelled "Language" throughout the module, including the name of the repo on Github and the class name. I think I have everything updated correctly now, so if anyone has already installed it, you will unfortunately need to install again. Sorry about that! 2
Zeka Posted November 25, 2016 Posted November 25, 2016 Thank you @adrian for so useful module. It would be super great to have opportunity to disable default language for some branches/pages 2
adrian Posted November 25, 2016 Author Posted November 25, 2016 Just now, Zeka said: Thank you @adrian for so useful module. Glad you like it 1 minute ago, Zeka said: Thank you @adrian for so useful module. It would be super great to have opportunity to disable default language for some branches/pages Perhaps you'd consider adding your support to my feature request: https://github.com/processwire/processwire-requests/issues/54 As far as I can tell there is no way for me to control which languages are displayed at the moment. If Ryan can come up with a core solution that lets me hook and change the results returned by $languages then I think I will be able to incorporate your request into this module. My goal is to have a checkboxes field added to the page edit Settings tab that lets you determine which languages are enabled for the page/branch.
Zeka Posted November 25, 2016 Posted November 25, 2016 1 minute ago, adrian said: My goal is to have a checkboxes field added to the page edit Settings tab that lets you determine which languages are enabled for the page/branch. ... sounds perfect. 1
adrianmak Posted December 14, 2016 Posted December 14, 2016 I don't know how to use it. I installed a multi-language profile. Enabling this module with "Disabled" However, editing an existing content, the multilanguage field still showing multilanguage Should I misunderstand the usage of this module ?
adrian Posted December 14, 2016 Author Posted December 14, 2016 @adrianmak - can you please post a screenshot of the settings for this module that are at the bottom of this page's Settings tab?
adrian Posted December 14, 2016 Author Posted December 14, 2016 @adrianmak - thanks for that. Sorry about the problem. Can you please try the new version I just committed. I have updated the modules directory, so it should be available from the update check. 1
adrianmak Posted December 14, 2016 Posted December 14, 2016 I updated the module. But the mentioned problem still exists. Even though multilanguage is disabled on a page, but multilanguage fields are still showing
adrian Posted December 14, 2016 Author Posted December 14, 2016 2 minutes ago, adrianmak said: I updated the module. But the mentioned problem still exists. Even though multilanguage is disabled on a page, but multilanguage fields are still showing Sorry about this. Can you please post the contents of the data field on the RestrictMultiLanguageBranch row of the PW modules db table?
adrianmak Posted December 14, 2016 Posted December 14, 2016 Are u referring the module config page ? 1
adrian Posted December 14, 2016 Author Posted December 14, 2016 No, I am looking for this - do you have access to PHPMyAdmin or similar to browse the PW "modules" table?
adrian Posted December 14, 2016 Author Posted December 14, 2016 Thanks - unfortunately it looks fine! I don't suppose there is any chance I can get access to this site to test a little? If not, we need to figure out why the module is not processing this page. I need to know that the multilanguageStatusCheck() methods is being called. If you have Tracy installed, could you replace that method with this: public function multilanguageStatusCheck(HookEvent $event) { $p = $event->object->getPage(); bd('pid:'.$p->id); // if actual noLang setting for this page's template is set to disabled (1) then exit now so we don't potentially enable if($p->template->noLang === 1) return; bd('OK1'); $parentsToMatch = array(); foreach($this->data['multilanguageStatus'] as $pid => $settings) { if($settings['onlyThisPage'] != 1 || $p->id === $pid) $parentsToMatch[] = $pid; } $pageMatchSelector = "id=".implode("|", $parentsToMatch); bd($pageMatchSelector); // parent() doesn't include current page $this->closestSpecifiedParent = $p->parent($pageMatchSelector); // closest() includes current page $this->closestMatch = $p->closest($pageMatchSelector); // if there's a match, set the noLang value for the page's template appropriately if(isset($this->data['multilanguageStatus'][$this->closestMatch->id])) { bd('match'); $p->template->noLang = ($this->data['multilanguageStatus'][$this->closestMatch->id]['status'] == 'disabled') ? '1' : '0'; } // if no match, then use default from config settings else { bd('no match'); $p->template->noLang = $this->data['multilanguageDefaultStatus'] == 'disabled' ? '1' : '0'; } } and then post a screenshot of the dumps panel for me.
adrianmak Posted December 14, 2016 Posted December 14, 2016 Please wait. I have to install the tracy module
adrianmak Posted December 14, 2016 Posted December 14, 2016 I installed tracy module. But I could not know how to operate it. Anyway, I could let you access the website as it is just a dummy default installation profile (nothing else). It is just for testing new modules for my own. frontendhttp://icy-pig-4792.vagrantshare.com/pw271/ adminhttp://icy-pig-4792.vagrantshare.com/pw271/processwire/ id: admin pass: 123456 1
adrian Posted December 14, 2016 Author Posted December 14, 2016 Ok, the problem is that you are running PW 2.5.3. Please try updating to 2.8 or 3.x. I don't think there is any way to make this module work with 2.5.3. 1
adrianmak Posted December 14, 2016 Posted December 14, 2016 it is running 2.7.1. The module is running on at least 2.8/3 ?
adrianmak Posted December 14, 2016 Posted December 14, 2016 anyway, I'm going to install pw 2.8 for a quick test.
adrianmak Posted December 14, 2016 Posted December 14, 2016 2.8 is working without an issue. 2.7.x is not working with this module. 1
adrian Posted December 14, 2016 Author Posted December 14, 2016 Glad to hear it's working with 2.8. Sorry about the issue with 2.7 - I think perhaps the "noLang" template setting must have been introduced in 2.8/3.x I'll update the modules directory to reflect this. Thanks for the help debugging! 1
neosin Posted March 15, 2018 Posted March 15, 2018 I just installed this module and with PW 3.0.95, Tracy shows me the following notices PHP Notice: Trying to get property of non-object in ...\RestrictMultiLanguageBranch.module:140 line 140 code: if($p->id === 1 || !isset($this->data['multilanguageStatus'][$this->closestSpecifiedParent->id])) { 1
adrian Posted March 15, 2018 Author Posted March 15, 2018 Thanks @neosin - it should be fixed in the latest version. Let me know if you find any issues. 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now