Memorial Day
Support will be closed on Monday, May 28th, 2012 to enjoy Memorial Day with our friends and families.
   
 
Conditional show div
Posted: 04 September 2010 08:37 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

I want to hide a div when there are no images in a custom field. The result is that when there ARE images in the custom field pagina_slideshow the div is shown. That’s OK. But when there are no images the div is still there and not hidden as expected.

It seems to me that this function only works with standard common custom fields and not with fields from a type like Channel Images or WYSIWYG editors.

So, how do I hide the div?

{if pagina_slideshow != ""}
        
<div id="slideshow">
          <!-- 
"previous page" action -->
          <
class="prevPage browse left"></a>
          <!-- 
root element for scrollable -->
          <
div class="scrollable">
            <
div class="items"{exp:channel_images:images entry_id="{entry_id}"<img src="{image:url}" alt="" /> {/exp:channel_images:images} </div>
          </
div>
          <!-- 
"next page" action -->
          <
class="nextPage browse right"></a>
          <!-- 
wrapper element for the large image -->
          <
div id="image_wrap">
            <!-- 
Initially the image is a simple 1x1 pixel transparent GIF -->
            <
img src="/graphics/layout/blank.gif" width="450" height="300" /> </div>
        </
div>{/if} 
Profile
 
 
Posted: 05 September 2010 02:19 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5126
Joined  06-20-2005

Hi Sjoerd,

It’s possible that other field types save their data in ways that mean that your conditional is always True. Please contact the authors of those field types to find the best way to test the status of those fields.

Cheers

Greg

 Signature 

   Purple Dogfish | Member of EE Pro Network | Follow me on Twitter

Profile
MSG
 
 
Posted: 05 September 2010 02:46 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  08-22-2010

Hi Sjoerd,

Instead of != try using the other way around.
Why not use == and try.

{exp:channel_images:images entry_id="{entry_id}"
{if pagina_slideshow 
== ""}
<div>&nbsp;</div> <!-- Display anything whatever you want when the pagina_slideshow is null -->
{/if}  
<div id="slideshow">
          <!-- 
"previous page" action -->
          <
class="prevPage browse left"></a>
          <!-- 
root element for scrollable -->
          <
div class="scrollable">
            <
div class="items"
               <
img src="{image:url}" alt="" /> 
            </
div>
          </
div>
          <!-- 
"next page" action -->
          <
class="nextPage browse right"></a>
          <!-- 
wrapper element for the large image -->
          <
div id="image_wrap">
            <!-- 
Initially the image is a simple 1x1 pixel transparent GIF -->
            <
img src="/graphics/layout/blank.gif" width="450" height="300" /> </div>
        </
div>
{/exp:channel_images:images} 

The idea here being, that if pagina_slideshow is equal to null, then display

<div>&nbsp;</div

(or anything.. you can choose)

Rest of the code which is enclosed in {exp:channel_images:images} doesn’t get executed.

Cheers..

 Signature 

There is always something others can teach us and vice-versa


A Design Idea

Profile
 
 
Posted: 05 September 2010 02:57 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

No, that doesn’t work unfortunately, however it comes close. The problem is here:

<div class="items"{exp:channel_images:images entry_id="{entry_id}"<img src="{image:url}" alt="" /> {/exp:channel_images:images} </div>
          </
div

The start and end of the images HAS to be within the div class=“items”...

Profile
 
 
Posted: 05 September 2010 03:01 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  08-22-2010

Do you want the div class = items to show/hide when pagina_slideshow is equal to null ?

Cheers

 Signature 

There is always something others can teach us and vice-versa


A Design Idea

Profile
 
 
Posted: 05 September 2010 03:03 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

No, the whole div ‘slideshow’.

Profile
 
 
Posted: 05 September 2010 03:06 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  08-22-2010

Which module is associated with custom field pagina_slideshow ?

For e.g.
{exp:channel:entries channel=“somechannel”}

Can you paste the whole code of the template .. it would help zero in the problem quickly :D

Cheers

 Signature 

There is always something others can teach us and vice-versa


A Design Idea

Profile
 
 
Posted: 05 September 2010 03:11 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

Channel Images

Profile
 
 
Posted: 05 September 2010 03:18 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  08-22-2010

Thanks for the Channel Images Addon link

However the issue is not with that.

It would be clear if you could paste the template code.

Cheers..

 Signature 

There is always something others can teach us and vice-versa


A Design Idea

Profile
 
 
Posted: 05 September 2010 03:26 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html >
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<
title>Pagina</title>
[removed][removed]
<link href="/css/devenen.css" rel="stylesheet" type="text/css" />
<
link href="/css/scroller.css" rel="stylesheet" type="text/css" />
{exp:edit_comments:javascript edit_link='pagina/edit_comment'}
</head>
<
body>
{exp:channel:entries channel="pagina"}
<div id="fond"><img src="{pagina_achtergrondfoto}" width="1280" height="837" alt="foto" /></div>
<
div id="wrapper">
  <
div id="header">
    <
div id="header_container">
      <
div id="header_nav_container_tekst">
        <
div id="header_nav"><a href="/">Home</a> | <a href="/contact">Contact</a> | <a href="/pagina/login">Login</a></div>
        
{embed="includes/zoek"</div>
      <
div id="logo"><a href="/"><img src="/graphics/layout/logo.png" width="174" height="80" alt="De Venen in het Groene Hart" /></a></div>
    </
div>
    <
div class="clear"></div>
  </
div>
  <
div id="content_container">
    <
div id="kol_container">
      <
div class="kol_240_links">
        <
div id="hoofdmenu"{exp:navee:nav nav_title="hoofdmenu" first_class="first" last_class="last" selected_class_on_parents="true"</div>
        <
div id="knop"> </div>
      </
div>
      <
div id="kol_490_midden">
        <
div class="padding_20">
          <
div id="tekst">
            <
h1>{title}</h1>
            
{pagina_tekst}</div>
        </
div>
        
{if pagina_slideshow != ""}
        
<div id="slideshow">
          <!-- 
"previous page" action -->
          <
class="prevPage browse left"></a>
          <!-- 
root element for scrollable -->
          <
div class="scrollable">
            <
div class="items"{exp:channel_images:images entry_id="{entry_id}"<img src="{image:url}" alt="" /> {/exp:channel_images:images} </div>
          </
div>
          <!-- 
"next page" action -->
          <
class="nextPage browse right"></a>
          <!-- 
wrapper element for the large image -->
          <
div id="image_wrap">
            <!-- 
Initially the image is a simple 1x1 pixel transparent GIF -->
            <
img src="/graphics/layout/blank.gif" width="450" height="300" /> </div>
        </
div>{/if}
        {if 
(member_group == '1' OR member_group == '5' OR member_group == '6')}
        
<div class="padding_20">
          <
div class="tekst">
            <
div class="reactie" id="reactie">
              <
div class="geplaatst_door_linkslijnend">Geplaatst door {author} <a href="{email}">{email}</aop {entry_date format="%d-%m-%Y"}{/exp:channel:entries}</div>
              <
div class="reacties_kop">Reacties</div>
              
{exp:comment:entries channel=channel="pagina" url_title="{segment_1}" sort="asc" limit="20"}
              
<div class="reactie_tekst_container">{exp:edit_comments:wrap_comment comment_id="{comment_id}" author_id="{author_id}"}
                {comment}{exp
:edit_comments:edit_link comment_id="{comment_id}" author_id="{author_id}"}
<div class="posted">{text}Reactie wijzigen{/text}</div>
{/exp:edit_comments:edit_link}
                {
/exp:edit_comments:wrap_comment}
                
<div class="geplaatst_door_rechtslijnend">Geplaatst door {name} op {comment_date format="%d-%m-%Y"}</div>
              </
div>
              
{/exp:comment:entries}
              
<div class="reactie_formulier_container">
                <
div class="groen_balkje">Plaats een reactie</div>
              </
div>
              
{exp:comment:form channel="pagina" url_title="{segment_1}"}
              
<div class="reactie_formulier">
                <
div class="reactieformulier_links">
                  <
label>
                    <
input type="checkbox" name="save_info" value="yes" {save_info} />
                    
Onthoud login</label>
                  <
br />
                  <
label>
                    <
input type="checkbox" name="notify_me" value="yes" {notify_me} />
                    
Email reacties</label>
                  <
p>&nbsp; </p>
                  <
input type="image" src="./graphics/layout/verzend.png" alt="Verzend reactie" width="66" height="24" border="0">
                </
div>
                <
div class="reactieformulier_rechts">
                  <
label for="comment">Mijn reactie:</label>
                  <
br />
                  <
textarea name="comment" class="textarea_300">{comment}</textarea>
                </
div>
              </
div>
              
{/exp:comment:form} </div>
          </
div>
        </
div>
        
{/if} </div>
      <
div id="kol_240_rechts"{exp:channel:entries channel="nieuws" orderby="date" sort="desc" limit="5" category_group="1" related_categories_mode="yes" custom_fields="yes"}
        
<div id="rechterkolom_nieuws_container">
          <
div class="rechterkolom_nieuws_thumb">{exp:imgsizer:size src="{nieuws_foto}" width="105" alt="{title}"}</div>
          <
h2>{title}</h2>
          
{nieuws_intro}
          {if no_results}
          
<div id="rechterkolom_nieuws_container">
            <
h2>Nieuws</h2>
            
Er zijn geen gerelateerde nieuwsonderwerpen.<br />
            <
br />
            <
a href="/nieuws/">Algemeen nieuws</a></div>
          
{/if}
          
<div class="leesmeer"><a href="{url_title_path='nieuws/pagina'}">Lees meer</a></div>
        </
div>
        
{/exp:channel:entries} </div>
      <
div class="clear"></div>
    </
div>
  </
div>
</
div>
Removed the javascripttoo long
</body>
</
html
Profile
 
 
Posted: 05 September 2010 03:39 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  08-22-2010

Try this code.. if pagina_slideshow is null it will display

<div class="empty">&nbsp;</div
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html >
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<
title>Pagina</title>
[removed][removed]
<link href="/css/devenen.css" rel="stylesheet" type="text/css" />
<
link href="/css/scroller.css" rel="stylesheet" type="text/css" />
{exp:edit_comments:javascript edit_link='pagina/edit_comment'}
</head>
<
body>
{exp:channel:entries channel="pagina"}
<div id="fond"><img src="{pagina_achtergrondfoto}" width="1280" height="837" alt="foto" /></div>
<
div id="wrapper">
  <
div id="header">
    <
div id="header_container">
      <
div id="header_nav_container_tekst">
        <
div id="header_nav"><a href="/">Home</a> | <a href="/contact">Contact</a> | <a href="/pagina/login">Login</a></div>
        
{embed="includes/zoek"</div>
      <
div id="logo"><a href="/"><img src="/graphics/layout/logo.png" width="174" height="80" alt="De Venen in het Groene Hart" /></a></div>
    </
div>
    <
div class="clear"></div>
  </
div>
  <
div id="content_container">
    <
div id="kol_container">
      <
div class="kol_240_links">
        <
div id="hoofdmenu"{exp:navee:nav nav_title="hoofdmenu" first_class="first" last_class="last" selected_class_on_parents="true"</div>
        <
div id="knop"> </div>
      </
div>
      <
div id="kol_490_midden">
        <
div class="padding_20">
          <
div id="tekst">
            <
h1>{title}</h1>
            
{pagina_tekst}</div>
        </
div>
        
{exp:channel:entries channel="pagina"}
            {if pagina_slideshow 
==""}
                
<div class="empty">&nbsp;</div>
            
{/if}

        
<div id="slideshow">
          <!-- 
"previous page" action -->
          <
class="prevPage browse left"></a>
          <!-- 
root element for scrollable -->
          <
div class="scrollable">
            <
div class="items"{exp:channel_images:images entry_id="{entry_id}"<img src="{image:url}" alt="" /> {/exp:channel_images:images} </div>
          </
div>
          <!-- 
"next page" action -->
          <
class="nextPage browse right"></a>
          <!-- 
wrapper element for the large image -->
          <
div id="image_wrap">
            <!-- 
Initially the image is a simple 1x1 pixel transparent GIF -->
            <
img src="/graphics/layout/blank.gif" width="450" height="300" /> </div>
        </
div>
       
{/exp:channel:entries}
        {if 
(member_group == '1' OR member_group == '5' OR member_group == '6')}
        
<div class="padding_20">
          <
div class="tekst">
            <
div class="reactie" id="reactie">
              <
div class="geplaatst_door_linkslijnend">Geplaatst door {author} <a href="{email}">{email}</aop {entry_date format="%d-%m-%Y"}{/exp:channel:entries}</div>
              <
div class="reacties_kop">Reacties</div>
              
{exp:comment:entries channel=channel="pagina" url_title="{segment_1}" sort="asc" limit="20"}
              
<div class="reactie_tekst_container">{exp:edit_comments:wrap_comment comment_id="{comment_id}" author_id="{author_id}"}
                {comment}{exp
:edit_comments:edit_link comment_id="{comment_id}" author_id="{author_id}"}
<div class="posted">{text}Reactie wijzigen{/text}</div>
{/exp:edit_comments:edit_link}
                {
/exp:edit_comments:wrap_comment}
                
<div class="geplaatst_door_rechtslijnend">Geplaatst door {name} op {comment_date format="%d-%m-%Y"}</div>
              </
div>
              
{/exp:comment:entries}
              
<div class="reactie_formulier_container">
                <
div class="groen_balkje">Plaats een reactie</div>
              </
div>
              
{exp:comment:form channel="pagina" url_title="{segment_1}"}
              
<div class="reactie_formulier">
                <
div class="reactieformulier_links">
                  <
label>
                    <
input type="checkbox" name="save_info" value="yes" {save_info} />
                    
Onthoud login</label>
                  <
br />
                  <
label>
                    <
input type="checkbox" name="notify_me" value="yes" {notify_me} />
                    
Email reacties</label>
                  <
p>&nbsp; </p>
                  <
input type="image" src="./graphics/layout/verzend.png" alt="Verzend reactie" width="66" height="24" border="0">
                </
div>
                <
div class="reactieformulier_rechts">
                  <
label for="comment">Mijn reactie:</label>
                  <
br />
                  <
textarea name="comment" class="textarea_300">{comment}</textarea>
                </
div>
              </
div>
              
{/exp:comment:form} </div>
          </
div>
        </
div>
        
{/if} </div>
      <
div id="kol_240_rechts"{exp:channel:entries channel="nieuws" orderby="date" sort="desc" limit="5" category_group="1" related_categories_mode="yes" custom_fields="yes"}
        
<div id="rechterkolom_nieuws_container">
          <
div class="rechterkolom_nieuws_thumb">{exp:imgsizer:size src="{nieuws_foto}" width="105" alt="{title}"}</div>
          <
h2>{title}</h2>
          
{nieuws_intro}
          {if no_results}
          
<div id="rechterkolom_nieuws_container">
            <
h2>Nieuws</h2>
            
Er zijn geen gerelateerde nieuwsonderwerpen.<br />
            <
br />
            <
a href="/nieuws/">Algemeen nieuws</a></div>
          
{/if}
          
<div class="leesmeer"><a href="{url_title_path='nieuws/pagina'}">Lees meer</a></div>
        </
div>
        
{/exp:channel:entries} </div>
      <
div class="clear"></div>
    </
div>
  </
div>
</
div>
Removed the javascripttoo long
</body>
</
html
 Signature 

There is always something others can teach us and vice-versa


A Design Idea

Profile
 
 
Posted: 05 September 2010 04:02 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

No, that doesn’t help unfortunately. Thanks for your kindfully help! As Greg Salt said: It’s possible that other field types save their data in ways that mean that your conditional is always True.

Greg: I already asked Brad Parscale from Channel Images. He was very helpful, but is seems to be a nasty problem. I know for sure there are lot of users who are struggling with this problem: hiding div’s when the field type is not common. Hope you can help me out!

Profile
 
 
Posted: 06 September 2010 01:48 AM   [ Ignore ]   [ # 12 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  14993
Joined  03-22-2004

Sjoerd,

To be honest I have haven’t often come across a third party fieldtype where I couldn’t test it’s condition.
Unfortunately this looks like an issue with the fieldtype and not with EE persay. What was Brad’s response?

Do you wish me to move this thread to the CodeShare Corner as it is more appropriate there?

Profile
 
 
Posted: 06 September 2010 03:28 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

Yes, OK. I hope Brad will have a closer look at it.

Profile
 
 
Posted: 07 September 2010 01:42 AM   [ Ignore ]   [ # 14 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  14993
Joined  03-22-2004

Moving to CodeShare as requested

Profile
 
 
Posted: 09 September 2010 02:25 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  01-27-2008

It is solved. Brad mailed me a test version and it’s OK. After updating and re-saving the entries it works fine. Brad will put the new version soon on his site. I used this tag: {if fieldname}content{/if}. Thanks for the help!

Profile