Karl_T Posted April 29, 2017 Share Posted April 29, 2017 I want to make some branches of a page list(tree) open onload. I am using Admin Custom Page module with the following code. <?php $p = $this->modules->get('ProcessPageList'); $p->set('id',1037); return $p->execute(); I changed the parent successfully from home to the wanted page, but the tree closed every time after reload. I added the following code before return $p->execute(): $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => array(1045,1046), )); The javascript shows error. Then I tried this: $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => 1045, )); The branch of the ID open with delay. I want to open multiple branches at the same time. Thanks. Link to comment Share on other sites More sharing options...
adrian Posted April 29, 2017 Share Posted April 29, 2017 Not sure if it suits your needs or not, but you can link to the admin page tree like this: http://mysite.com/processwire/page/?open=1045&open=1046 Sorry, ignore that (only works for one ID) and I have to run, so can't investigate further right now. Link to comment Share on other sites More sharing options...
Robin S Posted April 30, 2017 Share Posted April 30, 2017 If you set an array to openPageIDs then it must be an array of page IDs as strings. For example: $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => array('1045','1046'), )); If you would like the convenience of passing multiple page IDs as a GET parameter you could do this in /site/ready.php: $this->addHookBefore('ProcessPageList::execute', function($event) { $branches = $this->sanitizer->intArray(json_decode($this->input->get->branches)); if(count($branches)) { $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => array_map('strval', $branches) )); } }); Then you would link to the page tree like this: /processwire/page/?branches=[1045,1046] 3 Link to comment Share on other sites More sharing options...
Karl_T Posted April 30, 2017 Author Share Posted April 30, 2017 1 hour ago, Robin S said: If you set an array to openPageIDs then it must be an array of page IDs as strings. For example: $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => array('1045','1046'), )); Thanks! This just works, although this has a 0.5 second delay due to separate ajax call. 1 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