We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36565
    • 73 Posts
    Hi BobRay,

    what is confusing is that at least one time, I did get some output into the rendered page from print("text"); in a plugin, I swear! smiley But it's gone.

    I have tried EmailResource but I couldn't get it to work a single time, don't know why.
    I installed it, checked the OnWebPagePrerender Event, assigned all the TVs to the relevant template and had a look at their values in the relevant resources.

    To "preview" a page, I suppose I have to click the button where in my German speaking backend it says "Anzeigen", left of the "Löschen" (Delete) button, in the button bar top-right, just below the navbar. This button yields no response other than the rendered resource. No different with "Show resource" from the context menu.

    But for now I'll try to pass $modx->resource->_output directly into the DB - I have the impression that might work. Luckily the resources in question already have their CSS inside.
      PHP illiterate MODx enthusiast
      • 36565
      • 73 Posts
      A simple question:
      While $modx->resource->_output gives me the output of the current resource (if I am right), how can I get the output of a resource given its ID?

      Thanks in advance!
        PHP illiterate MODx enthusiast
      • discuss.answer
        • 36565
        • 73 Posts
        OK, I've got it made, finally.

        I fetch the resource via file_get_contents, but in an authenticated context:
            $url = $modx->makeUrl($modxid,'','','full');
            $username = 'user';
            $password = 'password';
          
            $context = stream_context_create(array(
                'http' => array(
                    'header'  => "Authorization: Basic " . base64_encode("$username:$password")
                )
            ));
            $desc = file_get_contents($url, false, $context);

        Now I update/insert the $desc into the database table using named placeholders in a prepared PDO statement.

        Thanks everybody for your awesomely awesome support!
          PHP illiterate MODx enthusiast