We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28755
    • 30 Posts
    how can i add the content generated by plugin in one placeholder?

    I had tried in this way
    ob_start();
    
    **code of my plugin**
    
    $output = ob_get_contents();
    ob_end_clean();
    
    $modx->setPlaceholder(placeholdername,$output);
    return;
    
    

    I set system event: OnWebPagePrerender

    but it doesn’t function..

    How can i do?

    Thanks in advance
      • 30223
      • 1,010 Posts
      I’ve never used plugins to set place holders but I believe that by the time the OnWebPagePrerender event is triggered all place holders will have been cleaned up.

      Try using a different event (onWebPageInit or onParseDocument) or create a place holder which is not recognized by MODx and replace that in your plugin.

      I don’t know what you’re trying to do but perhaps there’s a different way of achieving it besides a plugin?
        • 28755
        • 30 Posts
        Thanks for the answer.. i had tried with this event onWebPageInit or onParseDocument, but it continues to not work.

        I am tring to include a statistics application.. the plugin is a php include, the application logs the visit and sometime (the first time the user visist the site) add a <script> tag

        The <script> tag must be added in a precise position of the page

        How can i do in different way or let’s work this way?

        Thanks!
          • 30223
          • 1,010 Posts
          Try turning off the page’s caching. ( Edit Document >>Page Settings >> Cacheable = no)

          You can also enable visitor tracking in the MODx configuration and try the OnLogPageHit event.
            • 28755
            • 30 Posts
            thanks for the answer

            in this time i had done some tests

            And i had set OnWebPageInit

            It doesn’t work above all because i coded
            $modx->setPlaceholder(placeholdername,$output);
            whitout ’ ’
            now it is $modx->setPlaceholder(’placeholdername’,$output);
            And work great..

            I didn’t know about OnLogPageHit.. i will try next time..

            Thanks!!