title: Joomla get menu item id
body: <p>I have a component that has a simple payment form. I just want to get the current menu item id. I've tried several things to get the id.</p>
  
  <pre><code>    //get the active menu item id
      $app = JFactory::getApplication();
      $menu   = $app-&gt;getMenu();
      $active   = $menu-&gt;getActive();
      $activeId = $active-&gt;id;
      JLog::add('active id is: '.$activeId); //I get nothing returned
  
      $currentMenuId = JSite::getMenu()-&gt;getActive()-&gt;id ;
      JLog::add('menu id is: '.$currentMenuId); //I get nothing returned
  
      //try to see what the current url is
      $currenturl = JURI::current();
      JLog::add('current url is: '.$currenturl); //I get mysite.com/index.php
  </code></pre>
  
  <p>I use <code>$activeId</code> code in my plugins without problems but it doesn't work in my component. What am I missing?</p>