title: Get Joomla jdoc in PHP?
body: <p>I am very new to Joomla, and I am trying to get the output of a <code>&lt;jdoc:include /&gt;</code> tag in PHP before the page is rendered.</p>
  
  <p>My menu is included like this: <code>&lt;jdoc:include type="modules" name="main menu" /&gt;</code>
  I am trying to count the <code>&lt;li&gt;</code> tags within the main menu. I have it setup like this:</p>
  
  <pre><code>$str = &lt;&lt;&lt; HTML
      &lt;jdoc:include type="modules" name="main menu" /&gt;
  HTML;
  $count = substr_count($str, '&lt;li&gt;');
  echo $count;
  echo $str;
  </code></pre>
  
  <p>The menu echoes like normal, but <code>$count</code> is always 0, like it hasn't parsed yet.</p>