Conditionals and Catchall Fields: How to Filter on a Catchall field internal field?
Posted: 22 March 2011 12:16 AM   [ Ignore ]
Wallflower
Rank
Total Posts:  2
Joined  2011-03-21

With a Catchall field is is possible to base a conditional on a catchall field?

To borrow the example code over on Devot-ee:

{exp:channel:entries channel="site"}

{
!-- CHECK IF {ADDRESS} FIELD IS POPULATED TO DETERMINE CONTENT IS DISPLAYED --}
  
<div class="details">
  
{customer_details}
    {contact_info}
      Name
{name}
      Address
{address}
      City
{city}
      State
{state}
      Zip
{zip}
    {
/contact_info}
  {
/customer_details}
  
</div>
{/exp:channel:entries} 

If I only want to my details DIV to display if the {address} field has been filled out,  if I want to get more granular, more sub-atomic, how would I do that?

[ Edited: 22 March 2011 12:29 AM by bseymore ]
Profile
 
 
Posted: 22 March 2011 01:43 AM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

A little messy, but this should do the trick:

{exp:channel:entries channel="site"}

{
!-- CHECK IF {ADDRESS} FIELD IS POPULATED TO DETERMINE CONTENT IS DISPLAYED --}

  {customer_details}
{if 
"{contact_info}{address}{/contact_info}" != ""}
  
<div class="details">
    
{contact_info}
      Name
{name}
      Address
{address}
      City
{city}
      State
{state}
      Zip
{zip}
    {
/contact_info}
  
</div>
{/if}
  {
/customer_details}
{
/exp:channel:entries} 
Profile
 
 
Posted: 23 March 2011 12:27 AM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  2
Joined  2011-03-21

Not all that messy—in fact, that is clean enough that I should have thought to give it a try. The only only tweak I had to make in my case—where I have multiple {customer_details}-like fields on my form—is to tweak it so the field name is included:

{customer_details_1}{contact_info}{address}{/contact_info}{/customer_details_1} 

Many many thanks.

Brooks

Profile