solved Form Designer: Check for field

serveion
@serveion
10 years ago
223 posts
hello

Am adding some field to audio module, for amazon iTunes google play and spotify url
but i would like to check field, in order for me to show them on the page, but i have no idea how to do it with form designer.

I found something code in the forums no long ago but i can't find it anymore.

                  
 {if $item.audio_itunes_url == 'on'} 

                        {else}

                        {/if}
<div>
     {if $item.audio_itunes_url == 'on'} 
                         <a href="#">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
     {else}
Don't show anything.
      {/if}
          <a href="{$item.audio_amazon_url}">{jrCore_image module="jrAudio" image="amazon-mp3.png"}</a>
          <a href="{$item.audio_spotify_url}">{jrCore_image module="jrAudio" image="spotify.png"}</a>
          <a href="{$item.audio_google_play_url}">{jrCore_image module="jrAudio" image="google_play.png"}</a>
                                        
 </div>
buy.png
buy.png  •  56KB

Fields.png
Fields.png  •  21KB


updated by @serveion: 04/01/16 04:51:49PM
serveion
@serveion
10 years ago
223 posts
Hello

I found a way to do it but am not sure if is the correct one. please let me know is there is a better way to do this thank you very much

<div>
 {if empty($item.audio_itunes_url)} 

 {else}
            <a href="{$item.audio_itunes_url}">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
  {/if}
                        
  {if empty($item.audio_amazon_url)}

  {else}
              <a href="{$item.audio_amazon_url}">{jrCore_image module="jrAudio" image="amazon-mp3.png"}</a>
   {/if}
   {if empty($item.audio_spotify_url)}

   {else}
               <a href="{$item.audio_spotify_url}">{jrCore_image module="jrAudio" image="spotify.png"}</a>
    {/if}
    {if empty($item.audio_google_play_url)}

    {else}
               <a href="{$item.audio_google_play_url}">{jrCore_image module="jrAudio" image="google_play.png"}</a>
     {/if}                                 
                                        
     </div>

updated by @serveion: 12/28/15 07:58:08PM
michael
@michael
10 years ago
7,772 posts
you can use ! for not empty
"if its not empty"
 {if !empty($item.audio_itunes_url)} 
            <a href="{$item.audio_itunes_url}">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
  {/if}

or you can check the string length
"if its length is greater than zero"
 {if strlen($item.audio_itunes_url) > 0} 
            <a href="{$item.audio_itunes_url}">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
  {/if}

or check that it is not just "" like
"if its contents are not nothing"
 {if $item.audio_itunes_url != ""} 
            <a href="{$item.audio_itunes_url}">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
  {/if}
serveion
@serveion
10 years ago
223 posts
Hello @michael

Thank you very Much.
douglas
@douglas
10 years ago
2,797 posts
You can also check to see if it is set like this:

{if isset($item.audio_itunes_url) && strlen($item.audio_itunes_url) > 0}
<a href="{$item.audio_itunes_url}">{jrCore_image module="jrAudio" image="ituneslogo.png"}</a>
{/if}



--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos

Tags