gornycreative Posted October 14, 2024 Share Posted October 14, 2024 A minor issue, but if a site isn't running multiple languages, the $language api var is null. There needs to be a null check on line 322 in the .module file, such as: if ($this->wire('languages')->count()) { $lang_id = $this->wire('languages')->getLanguage()->id; } to: if ($this->wire('languages') && $this->wire('languages')->count()) { $lang_id = $this->wire('languages')->getLanguage()->id; } 1 Link to comment Share on other sites More sharing options...
Juergen Posted October 14, 2024 Author Share Posted October 14, 2024 Thanks for reporting this issue!! 😃 I have fixed this bug yesterday, but I have not bumped up the module version, because I am optimizing the code at the moment. So please replace the current file on Github with yours and everything should be fine. Best regards 1 Link to comment Share on other sites More sharing options...
gornycreative Posted October 15, 2024 Share Posted October 15, 2024 Cool. I should've check issues on github first. Thanks! Link to comment Share on other sites More sharing options...
MarkE Posted 2 hours ago Share Posted 2 hours ago Hi @Juergen. This is a nice module, but unfortunately it becomes unusable when there are a lot of pages. This is because on every page edit it autoloads and runs getParentPages() which has the following: return wire('pages')->find('id!=' . $exclude_pages . ',templates_id=' . $templates); On one site of mine this takes 20 seconds to run - so that's how long it takes to load a page in the back end. I'm only using the publish/unpublish functionality, so I disabled everything else and it loaded in a flash. However, that's not a solution if you want an 'after' action, so I looked into it a bit more. On my problem site, I have lots of parents and templates but I am only using the module on 2 templates which have a total of 47 pages, so I would have thought it would be possible to write it more efficiently. The problem seems to be that the above code is run on every page edit, not just pages of templates where the 'jk_...' fields are enabled. That means that, unless restricted parents are defined for every parent, the 'find' will run across all pages, with a large template array to match. I suggest adding the following after line 224 if(!in_array($this->page->template->id, array_keys($this->input_templates))) { return new PageArray(); } Then if, for the relevant templates, the allowed parents are set, it all runs pretty swiftly. Link to comment Share on other sites More sharing options...
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