Jump to content

JkPublishPages - Module to publish/unpublish, trash/delete or move a page depending on dates and times


Juergen
 Share

Recommended Posts

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;
                        }

 

  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...