Body: <p>I'm referencing the Pixel &amp; Tonic sample craft template Happy Lager where in the article body template there's a macro to get the position of a block.</p>
  
  <p>I'm trying to setup a conditional to check if the previous position of a block has been set to 'left'.</p>
  
  <pre><code>{% if prevPosition == 'left' %}
  </code></pre>
  
  <p>But that doesn't seem to work at all.</p>
  
  <p><a href="https://github.com/pixelandtonic/HappyLager/blob/master/craft/templates/_includes/article_body.html" rel="nofollow">https://github.com/pixelandtonic/HappyLager/blob/master/craft/templates/_includes/article_body.html</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-18T21:22:38.830Z
Comments.Text: What is `prevPosition`? `{{dump(prevPosition)}}` to display it...
Comments.UserDisplayName: Marion Newlevant
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-18T21:26:45.990Z
Comments.Text: It's NULL even though the previous block has position left.
Comments.UserDisplayName: Niall Thompson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-18T21:35:01.190Z
Comments.Text: Just looking at that macro, `prevPosition` should be set properly in lines 32-184. You need to be sure it is defined outside of the for loop (line 20), or else you will get a new, `null` one every time.
Comments.UserDisplayName: Marion Newlevant
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-21T22:26:32.300Z
Comments.Text: Where are you trying to insert this conditional? Inside the macro?
Comments.UserDisplayName: André Elvan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-21T22:27:42.820Z
Comments.Text: No outside in the article body template
Comments.UserDisplayName: Niall Thompson
Tags: <conditional><macro>
Title: Conditional to check position of previous matrix block
ThreadText: # Conditional to check position of previous matrix block
  
  (Asked by: username_0 on 2016-01-18)
  
  I'm referencing the Pixel & Tonic sample craft template Happy Lager where in the article body template there's a macro to get the position of a block.
  
  I'm trying to setup a conditional to check if the previous position of a block has been set to 'left'.
  
  ```
  {% if prevPosition == 'left' %}
  
  ```
  
  But that doesn't seem to work at all.
  
  <https://github.com/pixelandtonic/HappyLager/blob/master/craft/templates/_includes/article_body.html>
  
  **Tags:** conditional, macro
  
  > **Comments:**
  > **username_1**: What is `prevPosition`? `{{dump(prevPosition)}}` to display it...  
  > **username_0**: It's NULL even though the previous block has position left.  
  > **username_1**: Just looking at that macro, `prevPosition` should be set properly in lines 32-184. You need to be sure it is defined outside of the for loop (line 20), or else you will get a new, `null` one every time.  
  > **username_2**: Where are you trying to insert this conditional? Inside the macro?  
  > **username_0**: No outside in the article body template  
  
  ---
  
  ## 0 answers
  
  