We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6158
    • 224 Posts
    # modx v0.9.5 以降を使っている人には無関係な話です。

    v0.9.2 で regClientStartupScript を使っても <script> タグが挿入されなかっ
    たので理由を調べました。


    manager/includes/document.parser.class.inc.php:381: outputContent()

    $this->documentOutput = $this->documentContent;

    // check for non-cached snippet output
    if (strpos($this->documentOutput, ’[!’)>-1) {
    $this->documentOutput = str_replace(’[!’, ’[[’, $this->documentOutput);
    $this->documentOutput = str_replace(’!]’, ’]]’, $this->documentOutput);

    // Parse document source
    $this->documentOutput = $this->parseDocumentSource($this->documentOutput);

    // Insert Startup jscripts & CSS scripts into template - template must have a <head> tag
    if ($js = $this->getRegisteredClientStartupScripts()) {
    // change to just before closing </head>
    // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent);
    (誤) $this->documentContent = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentContent);
    (正) $this->documentOutput = preg_replace("/(<\/head>)/i", $js."\n\\1", $this->documentOutput);
    }

    // Insert jscripts & html block into template - template must have a </body> tag
    if ($js = $this->getRegisteredClientScripts()){
    (誤) $this->documentContent = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentContent);
    (正) $this->documentOutput = preg_replace("/(<\/body>)/i", $js."\n\\1", $this->documentOutput);
    }
    }
    documentContent を一旦 documentOutput に代入して処理を行おうとしている
    にもかかわらず、途中で元の documentContent を編集しているのが間違いだと
    思います。既に報告されている件だとは思いますが。

    こんな書き間違いが未だ他にも残ってそう。