Support » Plugin: PHP Code Widget » eval error or if statement not working

  • Resolved J

    (@paradox_designs)


    I am using this in conjunction with the Advanced Custom Fields plugin. (so the_field() code is related to that)

    Here is the code:

    <?php if ( the_field('downloadable_material') != ") { ?>
    <div class="material">
    <h4>Supplemental Material:</h4>
    <a href="<?php the_field('downloadable_material'); ?>"><i class="icon-download-alt"></i> - Download Supplemental Material</a>
    </div>
    <?php } else { }; ?>

    If downloadable_material (a file attachement field) has a file, it shows up and links correctly.
    if it is empty the whole thing still shows up on the page, (but with an empty link).

    The similar thing is happening with another statement in the same widget:

    <?php if ( the_field('links_and_resources') != " ) { ?>
    <h4>Resources:</h4>
    <p><?php the_field('links_and_resources'); ?></p>
    <?php } else { }; ?>

    Now this second one works in a strange way. it shows nothing when empty and shows the content of the field when it has something but it does not show the h4 “Resources:” at all. and if I add the <div class="material"></div> wrapped around the two lines between the if statement it generates the same error as below.

    I assumed the if statement was not written correctly. but any change I make to it results in the following error:

    Parse error: syntax error, unexpected T_STRING in execphp.php(44) : eval()’d code on line 5

    Any idea what is off here?

    Thanks

    http://wordpress.org/extend/plugins/php-code-widget/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘eval error or if statement not working’ is closed to new replies.