We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36451
    • 264 Posts
    Quote from: Frank at May 08, 2008, 06:53 AM

    And should i just place a call to this snippet somewhere in my template? Or do I need to change more in this script?
    No. Use this snippet in place of [*content*] in your template. Turn your adsense script into a chunk called "AdSense"and call it from this snippet:
    <?php
    $where = 1; //insert chunk after # </p>
    $content = $modx->documentObject['content'];
    $content = explode('</p>', $content);
    for ($i = 0; $i<count($content); $i++){
    	if ($i == $where) {
    		echo $modx->getChunk('AdSense'); 
    		}
    	echo $content[$i] . '</p>';
    	}
    ?>
    
      • 10076
      • 1,024 Posts
      could this only be in the document content? Say I want it in a sidebar. Should that be done through a TV?
        • 36451
        • 264 Posts
        In this case you will not need a snippet like that. Instead you would simply insert the {{AdSense}} call into your template.
          • 2762
          • 1,198 Posts
          is there an alternative to this nice snippet, for revolution?

          can be converted?

          edit: done

          $where = 1; //insert chunk after # </p>
          $content = $modx->resource->content;
          $content = explode('</p>', $content);
          for ($i = 0; $i<count($content); $i++){
              if ($i == $where) {
                  echo $modx->getChunk('AdSense');
                  }
              echo $content[$i] . '</p>';
              }
          
          [ed. note: banzai last edited this post 13 years, 2 months ago.]
            Free MODx Graphic resources and Templates www.tattoocms.it
            -----------------------------------------------------

            MODx IT  www.modx.it
            -----------------------------------------------------

            bubuna.com - Web & Multimedia Design