Conditional statement in custom template file using Display Suite I've been searching and scratching my head for a while on this one. I'm working on a blog page where the user can tag posts, but it is not required. I only want to output the label 'Category' if tags actually exist, so I need a conditional statement in my node template but I can't figure out the correct logic for doing so. This is what I have so far...

&lt;?= if (isset($node-&gt;$content['tags'][0]['value'])): ?&gt;
    &lt;p class="label"&gt;&lt;?= t("Category"); ?&gt;&lt;/p&gt;
    &lt;p class="category"&gt;&lt;?= render($content['tags']); ?&gt;&lt;/p&gt;
&lt;?= endif; ?&gt;


This code gives the following PHP error referring to the first line of the block of code

PHP Parse error:  syntax error, unexpected T_IF


I'm a Drupal novice so I'm expecting it to be something simple that I am missing or potentially just completely the wrong code.
First, you have a syntax error. Your server might not have been configured to allow short tags. 

Try using &lt;?php echo instead of &lt;?=

Second, you could either use the Field formatter conditions module to add display conditions to your fields or create a custom code field in Display Suite.

EDIT: How to  add a Display Suite custom code field in your own module:

1- Create a new module and add this code in it (remember to change MY_MODULE with the desired name):

/**
 * Implements hook_ds_fields_info().
 *
 * We add the code fields to Display Suite here.
 * Then we specify a callback function that will handle the display logic.
 */
function MY_MODULE_ds_fields_info($entity_type) {
  $fields = array();

  // Add a new custom code field. It should be available in Display Suite.
  $fields['node']['tags_custom'] = array(
    'title' =&gt; t('Tags (custom)'),
    'field_type' =&gt; DS_FIELD_TYPE_FUNCTION,
    'function' =&gt; 'MY_MODULE_ds_field_tags_custom',
  );

  if (isset($fields[$entity_type])) {
    return array($entity_type =&gt; $fields[$entity_type]);
  }
}

/**
 * Callback to show the tags field only if it has a value.
 */
function MY_MODULE_ds_field_tags_custom($field) {
  $node = $field['entity'];

  // Get the tags field value.
  $tags = isset($node-&gt;content['tags'][0]['value']) ? $node-&gt;content['tags'][0]['value'] : NULL;

  // Return a string or nothing, depending on the tags field value.
  if (!empty($tags)) {    
    return t('Category: ') . $node-&gt;content['tags'][0]['value'];
  }
  else {
    return NULL;
  }
}


2- Now, if you go to admin/structure/ds and click on the Manage display link, you will see your new field Tags (custom). Set its label to hidden and publish it in the desired area.