Give help. Get help.

  • # October 14, 2012 at 8:51 pm

    Here’s my code. In case it isn’t obvious what I’m trying to do, I want to only show the image if there is info in the field. And the link around the image uses the info in the field. The mailto: is coming up blank. So I’m guessing/hoping I’m doing something wrong with the way I’m printing/calling it. I would greatly appreciate any help.

    < ?php $email = types_render_field ("email");
    if ( $email ) { ?>

    # October 14, 2012 at 10:27 pm

    Try this:

    < ?php
    $email = types_render_field (“email”);
    if (!empty($email)) {
    isset might work better for you.

    EDIT: Also, your $empty variable right after the mailto is missing a semicolon. ;)

    # October 14, 2012 at 11:26 pm

    Thanks for looking at this.

    < ?php print $email; ?> knocks it out of the HTML it’s in. So instead of an image wrapped in a URL, I get"> IMAGE

    pmac627, your solution doesn’t work for me either. I still get a blank value for my string. And I’ve tested other fields, to make sure it isn’t just this field. I will look into isset though. Thanks for the recommendation.

    # October 15, 2012 at 8:29 am

    Perhaps try echo $email; instead? Good call, @traq. I can’t believe I missed that as well.

    Try to echo $email somewhere on the page to make sure that it actually contains a value.

    # October 15, 2012 at 9:38 am

    This will do the trick:

    Don’t know why the markup of this is so shit. But copy it in your code and make it look more nice.

    `< ?php
    // Get the e-mail variable
    $email = types_render_field (“email”);

    // Print out the e-mail variable, to make sure you’ve got one
    echo “

    " . print_r($email) . "


    // Check for an e-mail address
    if ( !empty($email) ) { ?>

    # October 16, 2012 at 9:35 pm

    Nope, I’ve tried echo before. It does the same thing as print — knocks it out of the href link and displays it on the page.

    And Vermaas, unless I’m missing something, yours is the same as pmac627 with just the print_r ($email) to test the content of the string. Am I getting that wrong?

    I’m hoping to have this site online for testing in a few days. Perhaps I can post a link then and get your thoughts.

    Again, thanks for trying.

    # October 16, 2012 at 10:13 pm

    I figured it out! It had to do with the way the custom field had been created. When it was an “email field”, it gave me that big mess. When I made it just a single line text field, it was fine.

    Thank you all for your help. (Especially since I was missing that echo in addition to everything else.)

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.