0

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.

1 Answer 1

1

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.

enter image description here

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' => t('My field'),
    'field_type' => DS_FIELD_TYPE_FUNCTION,
    'ui_limit' => array('node_type|*'),
    'function' => 'my_module_callback_function',
  );

  return array('node' => $fields);
}

function my_module_callback_function(&$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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.