Results 1 to 7 of 7

Thread: IF question

  1. #1
    Join Date
    Aug 2007
    Posts
    12

    Default IF question

    How do I set up my detail page to NOT show a custom field if the user has not entered information for it. For instance, I have a custom field for street address:

    Code:
        <label>Address</label>
        <span class="text2"><%$address1%><br/><%$city%>, <%$state%> <%$zip%><br/></span>
    It is not required, so if the user does not enter their street address, how can I get the detail page to not show the address field, because it is blank?

  2. #2
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    This is now it's done in PHP, I don't know if this will work exactly the same in IndexU

    if $address1==''
    { echo ""; }
    else
    { echo $address1; }

  3. #3
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    heres the code, for a fictional custom field called "address1" you dotn need the else, but i put it down so you could see how it worked if you needed it.

    <%if address1 %>
    <% address1 %>
    <%else%>
    <!-- do nothing -->
    <%/if%>
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  4. #4
    Join Date
    Aug 2007
    Posts
    12

    Default

    Ok, I realize now, I mispoke a little bit, as I often do. I don't want any of the Address info to show up....Label, adress, city, state, zip...unless an address has been entered. Sorry for my confusion. I imagine it is the same concept, so I'll play with this stuff a little bit.

  5. #5
    Join Date
    Aug 2007
    Posts
    12

    Default

    <%if address1 %><label>Address</label>
    <span class="text2"><%$address1%><br/><%$city%>, <%$state%> <%$zip%><br/></span>
    <%else%>
    <!-- do nothing -->
    <%/if%>

    Tried this, but does not work.

  6. #6
    Join Date
    Aug 2007
    Posts
    12

    Default

    sorry for the triple post but I got it to work using this:

    <%if ($address1)%><label>Address</label>
    <span class="text2"><%$address1%><br/><%$city%>, <%$state%> <%$zip%><br/></span>
    <%else%>
    <!-- do nothing -->
    <%/if%>

  7. #7
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    yep sorry i missed off the $ in the if statement, you dont actually need the brackets () but if it works with them, i guess it doesn't matter
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

Similar Threads

  1. I have a question, plz look.
    By Arthur32 in forum v5.x
    Replies: 1
    Last Post: 08-20-2006, 07:00 PM
  2. here's a question for you
    By gnr in forum Pre-Sales Questions
    Replies: 2
    Last Post: 12-21-2004, 05:09 AM
  3. question
    By Enigma in forum Pre-Sales Questions
    Replies: 2
    Last Post: 10-19-2004, 10:32 AM
  4. Hi, Ask question
    By sorn100 in forum Pre-Sales Questions
    Replies: 2
    Last Post: 07-28-2004, 02:33 AM
  5. A question!
    By MikeMc in forum v5.x
    Replies: 1
    Last Post: 01-23-2003, 08:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •