title: Joomla module, get menu id (ItemID) from article ID
body: <p>So i've been searching and testing for a couple days and can't seem to figure this out. </p>
  
  <p>I'm using the K2 content module and I need to add "?Itemid=111" to the end of the URL's it generates for the "Read More" link on pages. </p>
  
  <p>This is not done by default and i've found where I can add it, but i'm having problems getting the Itemid (menu id) from the article id.  </p>
  
  <p>All the examples i've found use</p>
  
  <pre><code>$app   = JFactory::getApplication();
  $menu   = $app-&gt;getMenu();
  $activeId = $menu-&gt;getActive()-&gt;id;
  </code></pre>
  
  <p>And that works, whenever you're on that page, and it does add the correct ID.  But for the articles I display on the homepage it does not work correctly as it adds the Itemid (menu id) of the homepage, and not the menu id of that specific article.</p>
  
  <p>Before when using Joomla 1.5 I would use the built-in function</p>
  
  <pre><code>getItemid($articleid)
  </code></pre>
  
  <p>That doesn't seem to work for me anymore.</p>
  
  <p>Does anybody have any suggestions or can anybody point me in the right direction on how I could solve this and "Get menu id (Itemid) from the article id"?</p>
  
  <p>Thanks!!!</p>