Answers.Body: <p><a href="https://craftcms.com/classreference/services/HttpRequestService#getParam-detail" rel="nofollow noreferrer"><code>craft()-&gt;request-&gt;getParam()</code></a> is only going to check for the value as part of the query string in the URI or in POST if it is a POST request, which is why it's returning null on the edit entry page in the control panel (it isn't in either).</p>
  
  <p>But since it <a href="https://craftcms.stackexchange.com/a/14526/57">looks like</a> you're using a template hook in your plugin, you can get the entry id directly from the context:</p>
  
  <pre><code>$entry = $context['entry'];
  
  if (!$entry-&gt;id)
  {
      // New entry
  }
  else
  {
      $entryId = $entry-&gt;id;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-13T17:56:43.147Z
Answers.LastActivityDate: 2016-10-13T17:56:43.147Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a plugin that's loaded on the edit page of an entry.</p>
  
  <p>Whenever I open the entry edit page, I would like to retrieve the id of this particular entry. I've tried this:
  <code>{% set someId = craft.request.getParam('entryId') %}</code></p>
  
  <p>But this just returns null.</p>
  
  <p>I need the id because I use it in my service: <code>craft.pluginName.getRecordByEntryId(someId)</code>.
  Which will return information that's bound to that page.</p>
  
  <p>I've also tried this:</p>
  
  <pre><code>{% for entry in craft.entries %}
  {% if entry.id %}
      &lt;p&gt;EntryId: &lt;input type="text" value="{{ entry.id }}"/&gt;&lt;/p&gt;
  {% endif %}{% endfor %}
  </code></pre>
  
  <p>But this will return all the entry id's, which I can't really use.</p>
  
  <p>Any help or advice on how I should tackle this differently?</p>
  
  <p>Thanks in advance!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-12T21:25:35.500Z
Comments.Text: How is your plugin getting loaded on the edit entry page?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-13T12:35:29.393Z
Comments.Text: Using this trick: http://craftcms.stackexchange.com/a/14526/5730
Comments.UserDisplayName: iNalgiev
Tags: <entry><error><null>
Title: craft.request.getParam('entryId') returns null on edit page of an entry
ThreadText: # craft.request.getParam('entryId') returns null on edit page of an entry
  
  (Asked by: username_0 on 2016-10-12)
  
  I have a plugin that's loaded on the edit page of an entry.
  
  Whenever I open the entry edit page, I would like to retrieve the id of this particular entry. I've tried this:
  `{% set someId = craft.request.getParam('entryId') %}`
  
  But this just returns null.
  
  I need the id because I use it in my service: `craft.pluginName.getRecordByEntryId(someId)`.
  Which will return information that's bound to that page.
  
  I've also tried this:
  
  ```
  {% for entry in craft.entries %}
  {% if entry.id %}
      <p>EntryId: <input type="text" value="{{ entry.id }}"/></p>
  {% endif %}{% endfor %}
  
  ```
  
  But this will return all the entry id's, which I can't really use.
  
  Any help or advice on how I should tackle this differently?
  
  Thanks in advance!
  
  **Tags:** entry, error, null
  
  > **Comments:**
  > **username_1**: How is your plugin getting loaded on the edit entry page?  
  > **username_0**: Using this trick: http://craftcms.stackexchange.com/a/14526/5730  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-10-13. Score: 1 | Accepted answer
  
  [`craft()->request->getParam()`](https://craftcms.com/classreference/services/HttpRequestService#getParam-detail) is only going to check for the value as part of the query string in the URI or in POST if it is a POST request, which is why it's returning null on the edit entry page in the control panel (it isn't in either).
  
  But since it [looks like](https://craftcms.stackexchange.com/a/14526/57) you're using a template hook in your plugin, you can get the entry id directly from the context:
  
  ```
  $entry = $context['entry'];
  
  if (!$entry->id)
  {
      // New entry
  }
  else
  {
      $entryId = $entry->id;
  }
  
  ```
  
  
  ---
  
  