Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use modx->controller->addJavascript breaks use in front-end #21

Open
BobRay opened this issue Dec 9, 2016 · 0 comments
Open

Use modx->controller->addJavascript breaks use in front-end #21

BobRay opened this issue Dec 9, 2016 · 0 comments

Comments

@BobRay
Copy link
Contributor

BobRay commented Dec 9, 2016

In the front end, this throws an error because $modx->controller is only instantiated in the modManagerResponse class.

I'm trying to make TinyMCE work with NewsPublisher again, but can't think of a good workaround for this.

I could add this code to NewsPublisher and call it, but what would the action be? And are there any other changes I'd need to make?

public function instantiateController($className,$getInstanceMethod = 'getInstance') {
        try {
            $c = new $className($this->modx,$this->action);
            if (!($c instanceof modExtraManagerController) && $getInstanceMethod == 'getInstanceDeprecated') {
                $getInstanceMethod = 'getInstance';
            }
            /* this line allows controller derivatives to decide what instance they want to return (say, for derivative class_key types) */
            $this->modx->controller = call_user_func_array(array($c,$getInstanceMethod),array(&$this->modx,$className,$this->action));
            $this->modx->controller->setProperties($c instanceof SecurityLoginManagerController ? $_POST : array_merge($_GET,$_POST));
            $this->modx->controller->initialize();
        } catch (Exception $e) {
            die($e->getMessage());
        }
        return $this->modx->controller;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant