I’m trying to create a template that will determine what content to show based on a conditional that evaluates segment_2.
<!-- determine county -->
{if "{segment_2}" == "belknap-county"}
<!-- belknap county -->
{exp:channel:entries channel="belknap_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "carroll-county"}
<!-- carroll county -->
{exp:channel:entries channel="carroll_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "cheshire-county"}
<!-- cheshire county -->
{exp:channel:entries channel="cheshire_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "coos-county"}
<!-- coos county -->
{exp:channel:entries channel="coos_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "grafton-county"}
<!-- grafton county -->
{exp:channel:entries channel="grafton_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "hillsborough-county"}
<!-- hillsborough county -->
{exp:channel:entries channel="hillsborough_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "merrimack-county"}
<!-- merrimack county -->
{exp:channel:entries channel="merrimack_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "rockingham-county"}
<!-- rockingham county -->
{exp:channel:entries channel="rockingham_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "stafford-county"}
<!-- stafford county -->
{exp:channel:entries channel="stafford_county_listings" dynamic="no"}
{if:elseif "{segment_2}" == "sullivan-county"}
<!-- sullivan county -->
{exp:channel:entries channel="sullivan_county_listings" dynamic="no"}
{if:else}
<h2>Not sure what county you are looking for…</h2>
<p> {/if}<br />
</p><h2>{title}</h2>
<p> {cty_page_content}<br />
{/exp:channel:entries}The conditional appears to be working properly because I can see the comments in the code that indicate which branch of the statement was evaluated. The (very) confusing part is that no matter what branch evaluates as true, I get channel entries for the first channel only (meaning the “belknap_county_listings” channel).
I’ve turned on template debugging and see the following, no matter what:
(0.011003 / 11.74MB) Tag: {exp:channel:entries channel="belknap_county_listings" dynamic="no"}
(0.011058 / 11.74MB) Closing Tag FoundAny thoughts on why this would be happening? Can you not use the opening channels tag in a conditional statement? My thoughts are that it’s parsing the tag, regardless of the conditional.