Answers.Body: <p><strong>Plugin alternative:</strong> </p>
  
  <pre><code>  public function statusIsLive($handle) {
      $section = craft()-&gt;sections-&gt;getSectionByHandle($handle);
      $criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
      $criteria-&gt;section = $section;
      return craft()-&gt;elements-&gt;findElements($criteria);
    }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T09:44:19.557Z
Answers.LastActivityDate: 2014-11-18T09:44:19.557Z
Answers.UserDisplayName: Mark Notton
Answers.Body: <p>This should work. </p>
  
  <pre><code>{% set policy = craft.entries.section('policy').first() %}
  {% if policy %}&lt;a href="{{ policy.url }}"&gt;{{ policy.title }}&lt;/a&gt;{% endif %}
  </code></pre>
  
  <p><code>ElementCriteriaModel</code> should only return active records by default.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T09:43:17.497Z
Answers.Text: Thanks Douglas, this is great. It worked and put me in the right direction to create a Plugin alternative too.
Answers.UserDisplayName: Mark Notton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-17T17:36:33.317Z
Answers.LastActivityDate: 2014-11-17T17:36:33.317Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>This is probably a really basic question, but I can't figure out how to check the status of a page before I link to it. </p>
  
  <p>I have a link in my footer to 'Policy' page. But if the page status is inactive, I don't want that link to show. How can I perform this simple check?</p>
  
  <p>Thanks,</p>
  
  <p>Mark</p>
  
Tags: <templating><navigation><conditional>
Title: How to link to a page, but only if the page status is active
ThreadText: # How to link to a page, but only if the page status is active
  
  (Asked by: username_0 on 2014-11-17)
  
  This is probably a really basic question, but I can't figure out how to check the status of a page before I link to it.
  
  I have a link in my footer to 'Policy' page. But if the page status is inactive, I don't want that link to show. How can I perform this simple check?
  
  Thanks,
  
  Mark
  
  **Tags:** templating, navigation, conditional
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-11-17. Score: 4 | Accepted answer
  
  This should work.
  
  ```
  {% set policy = craft.entries.section('policy').first() %}
  {% if policy %}<a href="{{ policy.url }}">{{ policy.title }}</a>{% endif %}
  
  ```
  
  `ElementCriteriaModel` should only return active records by default.
  
  > **Comments:**
  > **username_0**: Thanks username_1, this is great. It worked and put me in the right direction to create a Plugin alternative too.  
  
  ---
  
  ### Answer by username_0 on 2014-11-18. Score: 0
  
  **Plugin alternative:**
  
  ```
    public function statusIsLive($handle) {
      $section = craft()->sections->getSectionByHandle($handle);
      $criteria = craft()->elements->getCriteria(ElementType::Entry);
      $criteria->section = $section;
      return craft()->elements->findElements($criteria);
    }
  
  ```
  
  
  ---
  
  