Jump to content

Same code as before now ineffective


hellomoto
 Share

Recommended Posts

class ImportUpdateUltimate extends Process {

    public static function getModuleInfo() {
        return array(
            'title' => 'Import & Update',
            'autoload' => 'template=admin',
            'singular' => false,
		);
	}

    public function execute() {
      $addnew = wire('config')->urls->admin . '/page/add/?parent_id=' . wire('page')->id . '&template_id=' . wire('templates')->get('name=importupdate')->id;
      $output = '
        <style>th,td { padding: 2px; } tr { border: 1px solid; } th { font-weight: bold; }</style>
        <p>Nulla laoreet tristique tristique. Sed elementum justo a nisl elementum sit amet accumsan nisi tempor. Nulla quis eros et massa dignissim imperdiet a vitae purus.</p>';
      $rows = '';
      foreach(wire('page')->children('include=all') as $iu) {
        $runnable = '<i class="fa fa-exchange"></i>';
        if($iu->is(Page::statusUnpublished)) $runnable = '';
        $rows .= '<tr><td><a href="' . $iu->editUrl . '">' . $iu->title . '</a></td><td></td><td><a href="' . $iu->url . '" target="#ajaxiframe">' . $runnable . '</a></td></tr>';
      }
      $output .= '<table><tr><th>Title</th><th>LazyCron</th><th>Run</th></tr>' . $rows . '</table>';
      $output .= '<a href="' . $addnew . '">+ New Import/Updater</a>';
      return $output;
    }

    public function install() {
      $pg = new Page();
      $pg->template = "admin";
      $pg->name = "importupdate";
      $pg->title = "Import/Update";
      $pg->save();
      $pg->process = "ImportUpdateUltimate";
      $admin = $this->pages->get(2); 
      $pg->set("parent", $admin)->save();
	}
}

That same code used to effectively assign the process module above itself as the page's process upon installing the module. Now it doesn't. How can I make it do so?

Link to comment
Share on other sites

Not sure but use this:

$pg->process = $this;

Since some time you can also do this in the module info as an array:

'page' => array( // optionally install/uninstall a page for this process automatically
        'name' => 'mymodulename',  // name of page to create
        'parent' => '',    // parent name (under admin) or omit or blank to assume admin root
        'title' => 'My Module',     // title of page, or omit to use the title already specified above
    )

https://github.com/ryancramerdesign/ProcessHello/blob/master/ProcessHello.info.php

Link to comment
Share on other sites

I'd tried that, both, now the module won't even actually install. (It creates the page all right, sans process, but the module itself is deactivated immediately.) This has all been since it started saying my request appears to be forged so I can't activate modules as normal, need $config->protectCSRF = false; in the site config.php.

For some reason now it works that I've put it in ready() instead... somehow... 


    public function ready() {
      $pg = $this->pages->get('name=importupdate');
      if($pg->process != $this) $pg->setOutputFormatting(false)->set('process', $this)->save();
    }

but it'll only install after 2 tries. 1st try it does create the page, but inevitably needs another attempt.

It was working just fine earlier just as I posted it, that's from my last commit which activated ok and all, I can't believe I've been bothering with this all damn night.

Link to comment
Share on other sites

I have no idea to be honest. I would also remove the autoload config since it a process module that shouldn't be autoload as it's loaded when the admin page is loaded. Also would add the other module infos as needed like summary. Otherwise I never had any problem with this. I would recommend giving all the infos about your setup and versions. 

And try the ProcessHello I linked to, if that installs ok. Otherwise you may have some other related problem with your install.

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

×
×
  • Create New...