Answers.Body: <p>There are a few ways I can think to do this. </p>
  
  <ol>
  <li><p>Create separate 'index.html' and 'home.html' templates.</p>
  
  <ul>
  <li>'index.html' would have a conditional to display the takeover based on your field value, whereas 'home.html' would not. Both however could make use of the same content using <code>{% include '/home.html' %}</code> within 'index.html'. The nav would then link to '/home' rather than '/'.</li>
  </ul></li>
  <li><p>Set up a custom route and test for the uri segment.</p>
  
  <ul>
  <li>If you want to use the same template you could also set a custom route so that '/home' points to your 'index.html' template, and then test for the uri segment using <code>{% if craft.request.getLastSegment() == 'home' %}... {% endif %}</code></li>
  </ul></li>
  <li><p>Pass a variable to the 'index.html' template when linking via nav</p>
  
  <ul>
  <li>If you pass a variable to your index page when accessed it through the primary nav (i.e. <code>/index.html?t=1</code>), you can then test for the variable using <code>{% if craft.request.getParam('t') %}... {% endif %}</code>. If the variable exists then don't display the takeover. Not a very pretty URI though.</li>
  </ul></li>
  <li><p>Write a small plugin to set a cookie.</p>
  
  <ul>
  <li>You could also write a small plugin, with a variables file that sets a cookie: (not tested)</li>
  </ul></li>
  </ol>
  
  <pre>
  class MyPluginVariable
  {
      public function setTakeoverTimeout()
      {
          $cookie = new HttpCookie('takeoverViewed', true);
          $cookie->expire = time() + 3600;
          craft()->request->getCookies()->add($cookie->name, $cookie);
      }
  }
  </pre>
  
  <p>and then in your template file test for (and set) the cookie using,</p>
  
  <pre>
  {% if not craft.request.getCookie('takeoverViewed') %}
      {{ setTakeoverTimeout }}
      display takeover content here
  {% endif %}
  </pre>
  
  <p>Another cookie example can be seen <a href="https://craftcms.stackexchange.com/questions/4583/best-way-to-use-savecookie-and-craft-request-getcookielocation/4585#4585">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T07:52:47.953Z
Answers.LastActivityDate: 2014-12-15T08:05:50.113Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <p>There's this nice little plugin <a href="https://github.com/lewisjenkins/craft-lj-cookies/" rel="nofollow">"LJ Cookies"</a> that allows you to set and retrieve cookies from your template. So you don't need to write your own plugin for this. Just install the plugin and use code like this on your landing page:</p>
  
  <pre><code>{# Retrieve the cookie's value #}
  {% set visited = craft.lj_cookies.get('visited') %}
  
  {# Don't show spezial HTML if user visited this page before #}
  {% if visited != 1 %}
      &lt;h1&gt;Hello stranger!&lt;/h1&gt;
  {% endif %}
  
  {# Set a cookie on the user's first visit #}
  {% do craft.lj_cookies.set('visited', '1', '', '/') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:09:03.597Z
Answers.Text: I'll have to check out that plugin. Is one of those properties a timeout?
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:12:40.300Z
Answers.Text: @Douglas I just edited the code, so that it sets the new cookie after trying to retrieve it.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:15:43.460Z
Answers.Text: Was just thinking you might want to set a timeout so that if they come back in an hour or tomorrow they will see it again. From the plugin docs... `{% do craft.lj_cookies.set('myname', 'myvalue', now | date_modify("+1 hour").timestamp ) %}`
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:15:43.933Z
Answers.Text: @Douglas it's a simple wrapper for the PHP [`setcookie`](http://php.net/manual/en/function.setcookie.php) function. So no, it doesn't allow you set a timeout. That third param is for the cookie duration.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:17:19.120Z
Answers.Text: duration.. that's what I meant to say ;)
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:17:46.777Z
Answers.Text: Ahhh ok, misunderstood what you meant with timeout. Thought you want it the other way around, to show it within the first couple of seconds...
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-15T08:03:52.273Z
Answers.LastActivityDate: 2014-12-15T08:23:40.953Z
Answers.LastEditDate: 2014-12-15T08:23:40.953Z
Answers.UserDisplayName: carlcs
Body: <p>I have a problem which may be very simple to solve, but I just can't get my head around it. </p>
  
  <p>I would like to do an alternative landing page if an image has been uploaded to the 'homepage' single entry by the client.</p>
  
  <p>This part is straightforward as I could just test if the image was there and if so enable a different piece of html from the normal index page of the site, this would function as my main entry page then.</p>
  
  <p>The problem I see is once a user clicks the homepage takeover they should be redirected to the normal index page. It seems that this will trigger the same bit of code again and will show the takeover page again though.</p>
  
  <p>I am probably over-thinking this one but is there a way to show the homepage takeover once and then if the user clicks through or selects the homepage from the nave it won't trigger the takeover to be shown again?</p>
  
  <p>Any help on this would be appreciated.</p>
  
Tags: <url><conditional>
Title: Homepage Takeover
ThreadText: # Homepage Takeover
  
  (Asked by: username_0 on 2014-12-15)
  
  I have a problem which may be very simple to solve, but I just can't get my head around it.
  
  I would like to do an alternative landing page if an image has been uploaded to the 'homepage' single entry by the client.
  
  This part is straightforward as I could just test if the image was there and if so enable a different piece of html from the normal index page of the site, this would function as my main entry page then.
  
  The problem I see is once a user clicks the homepage takeover they should be redirected to the normal index page. It seems that this will trigger the same bit of code again and will show the takeover page again though.
  
  I am probably over-thinking this one but is there a way to show the homepage takeover once and then if the user clicks through or selects the homepage from the nave it won't trigger the takeover to be shown again?
  
  Any help on this would be appreciated.
  
  **Tags:** url, conditional
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-12-15. Score: 4 | Accepted answer
  
  There's this nice little plugin ["LJ Cookies"](https://github.com/lewisjenkins/craft-lj-cookies/) that allows you to set and retrieve cookies from your template. So you don't need to write your own plugin for this. Just install the plugin and use code like this on your landing page:
  
  ```
  {# Retrieve the cookie's value #}
  {% set visited = craft.lj_cookies.get('visited') %}
  
  {# Don't show spezial HTML if user visited this page before #}
  {% if visited != 1 %}
      <h1>Hello stranger!</h1>
  {% endif %}
  
  {# Set a cookie on the user's first visit #}
  {% do craft.lj_cookies.set('visited', '1', '', '/') %}
  
  ```
  
  > **Comments:**
  > **username_1**: I'll have to check out that plugin. Is one of those properties a timeout?  
  > **username_2**: @username_1 I just edited the code, so that it sets the new cookie after trying to retrieve it.  
  > **username_1**: Was just thinking you might want to set a timeout so that if they come back in an hour or tomorrow they will see it again. From the plugin docs... `{% do craft.lj_cookies.set('myname', 'myvalue', now | date_modify("+1 hour").timestamp ) %}`  
  > **username_2**: @username_1 it's a simple wrapper for the PHP [`setcookie`](http://php.net/manual/en/function.setcookie.php) function. So no, it doesn't allow you set a timeout. That third param is for the cookie duration.  
  > **username_1**: duration.. that's what I meant to say ;)  
  > **username_2**: Ahhh ok, misunderstood what you meant with timeout. Thought you want it the other way around, to show it within the first couple of seconds...  
  
  ---
  
  ### Answer by username_1 on 2014-12-15. Score: 4
  
  There are a few ways I can think to do this.
  
  1. Create separate 'index.html' and 'home.html' templates.
  
     * 'index.html' would have a conditional to display the takeover based on your field value, whereas 'home.html' would not. Both however could make use of the same content using `{% include '/home.html' %}` within 'index.html'. The nav would then link to '/home' rather than '/'.
  2. Set up a custom route and test for the uri segment.
  
     * If you want to use the same template you could also set a custom route so that '/home' points to your 'index.html' template, and then test for the uri segment using `{% if craft.request.getLastSegment() == 'home' %}... {% endif %}`
  3. Pass a variable to the 'index.html' template when linking via nav
  
     * If you pass a variable to your index page when accessed it through the primary nav (i.e. `/index.html?t=1`), you can then test for the variable using `{% if craft.request.getParam('t') %}... {% endif %}`. If the variable exists then don't display the takeover. Not a very pretty URI though.
  4. Write a small plugin to set a cookie.
  
     * You could also write a small plugin, with a variables file that sets a cookie: (not tested)
  
  ```
  
  class MyPluginVariable
  {
      public function setTakeoverTimeout()
      {
          $cookie = new HttpCookie('takeoverViewed', true);
          $cookie->expire = time() + 3600;
          craft()->request->getCookies()->add($cookie->name, $cookie);
      }
  }
  
  ```
  
  and then in your template file test for (and set) the cookie using,
  
  ```
  
  {% if not craft.request.getCookie('takeoverViewed') %}
      {{ setTakeoverTimeout }}
      display takeover content here
  {% endif %}
  
  ```
  
  Another cookie example can be seen [here](https://craftcms.stackexchange.com/questions/4583/best-way-to-use-savecookie-and-craft-request-getcookielocation/4585#4585).
  
  
  ---
  
  