Skip to content

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

Open
@BobRay

Description

@BobRay

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions