Using php if else statement in display suite Ok i purchased a theme from themeforest called wunderkind.

I liked most of the things about it except for the blog page.  I liked the more traditional look of the summary image/video on the right and the blog summary on the left. Instead of one on top of the other.

So I am using display suites to layout the blog teaser and everything is working fine except that the blog article content type is dynamic.  You can have either a standard post or a video post.  If you choose video then a video URL field appears, and if you choose image then an image field appears.

I am trying to figure out how to create a code field in display suites that will either display the image or display an iframe with the video url.

The other route I am considering is simply creating a field in the blog called summary image and have it display on the main blog page.

Any help would be appreciated.
If your need is simple, a "hide when empty" for example, you definitely need to look into Field formatter conditions module, it will allow you do simple conditions on your field formatters for a given view mode.



If that's not enough, Display Suite allows to have arbitrary fields added to the view modes, you need to look into hook_ds_fields_info and implement it in a custom module for your needs.

/**
 * Implements hook_ds_fields_info()
 */
function my_module_ds_fields_info($entity_type) {
  $fields = array();

  $fields['my_field'] = array(
    'title' =&gt; t('My field'),
    'field_type' =&gt; DS_FIELD_TYPE_FUNCTION,
    'ui_limit' =&gt; array('node_type|*'),
    'function' =&gt; 'my_module_callback_function',
  );

  return array('node' =&gt; $fields);
}

function my_module_callback_function(&amp;$field) {
  // Here goes your code, the conditions to display or not another field
  // and return an array with the data.
}


Further examples in https://stackoverflow.com/questions/16253312/using-hook-ds-fields-info-is-there-a-way-to-use-standard-formatters-so-the-op and http://www.previousnext.com.au/blog/creating-custom-display-suite-fields-or-how-i-learned-stop-worrying-and-use-hookdsfieldsinfo