Skip to main content

How do you add conditional variables to liquid?

I am building a site for a client where they vet and vote on endorsing candidates for public office. I created a blog page viewable only by staffers to enter information on new candidates that have qualified for consideration. 

I then created a "New Candidates" page and added the liquid and partial templates so a portion of the information will show up on the page under their respective state by adding a "georgia" tag or "north_carolina" tag.

<h3>GEORGIA</h3>
{% tag "georgia" with "ga_posts" %}
<br>
<h3>NORTH CAROLINA</h3>
{% tag "north_carolina" with "nc_posts" %}
<br>
<h3>NEW JERSEY</h3>
{% tag "new_jersey" with "nj_posts" %}
<br>
<h3>SOUTH CAROLINA</h3>
{% tag "south_carolina" with "sc_posts" %}
<br>
<h3>TEXAS</h3>
{% tag "texas" with "tx_posts" %}
<br>
<h3>VIRGINIA</h3>
{% tag "virginia" with "va_posts" %}

I will use liquid and partial templates on each state page (once I've built those) so that the  candidates show up on the appropriate state page.

My question is this. At some point, we will have an "Endorsed Candidates" page. Instead of staffers having to go back and add the information about a candidate manually to the Endorsed Candidates page under the respective state is it possible to write conditional liquid so they can go back to the original post of the candidate's information and add an 'endorsed' tag so the information shows up on the Endorsed page under their respective state ie,

<h3>NORTH CAROLINA</h3>
{% tag "north_carolina" AND "endorsed" with "nc_posts" %}


Official response from

Hello Brad!

As it happens, NationBuilder supports an "and" operator as part of our Liquid syntax. To learn more (and to see some sample code), check out our 'How to use Liquid' page.

-- Ian

Share this post

Showing 6 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.