ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to display conditional data from a channel

March 31, 2011 1:51am

Subscribe [2]
  • #1 / Mar 31, 2011 1:51am

    grounded

    138 posts

    Hello,

    I need to know how to do something, i would think to be somewhat basic. I will set this up, and link to the live site where this example can be found.

    I have a website that is dynamically pulling channel data to create a list of ‘personnel’ associated with the industry this website is directed at. For each ‘personnel’ page, you can view each personnel as an individual page, ex http://www.onami.us/index.php/Terri_fiez
    or in a table that displays the full list of personnel, (ordered by last name) http://www.onami.us/index.php/nano-network/contact_a_researcher.

    When entering a new ‘personnel’ page. there are of course multiple fields for name / last name / bio / specialty / image / email / etc .
    What i need to be able to do, is IF the person does not have a website to fill in in the field for that channel, then the link for that persons
    website should not show up on the individual page. ex http://www.onami.us/index.php/Robert_bass You see that there is a link at the bottom of this page to click on his link.

    How do I tell EE that if there is no website entered into the website field for that entry, then DO NOT display the line of code in page template -

    <a href="http://{website}" target="blank" rel="noopener"> <h3>Visit this researcher's website HERE</h3></a>

    Any help is appreciated.

    Ed

  • #2 / Mar 31, 2011 2:05am

    Cheif

    626 posts

    {if website != ""} //If your custom field isn't empty - there must be something there!
    //show me the money
    <a href="http://{website}" target="blank" rel="noopener"> <h3>Visit this researcher's website HERE</h3><p></a>  <br />
    {if}

  • #3 / Mar 31, 2011 2:17am

    grounded

    138 posts

    I replaced with the above code, and this makes the whole page not show up. (blank white page).
    what am i suppose to put in the ‘//If your custom field isn’t empty - there must be something there!
    //show me the money’  area?

  • #4 / Mar 31, 2011 4:01am

    Cheif

    626 posts

    Anything preceeded with // is a comment and should be removed and you’ll need to fix the end {if} to {/if}

  • #5 / Mar 31, 2011 10:04am

    Sue Crocker

    26054 posts

    Thanks for the assist, Cheif.

    grounded, if you fix the second if to have {/if}, does that help?

  • #6 / Mar 31, 2011 11:25pm

    grounded

    138 posts

    ill try tonight, thanks…

  • #7 / Apr 01, 2011 3:28am

    grounded

    138 posts

    I think that did it! all looks to be working properly!
    thanks guys,

    Ed

  • #8 / Apr 01, 2011 7:28am

    Sue Crocker

    26054 posts

    Glad to hear. Ed - Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases