1

How I can remove the node id when I override a node layout with Display Suite?

In some (old) how-to I noticed that the id node is not present when a node layout is overridden with DS.

i.e.: from this

<div id="node-1" class="ds-1col node node-page clearfix clearfix view-mode-full content clearfix" typeof="foaf:Document" about="/node/1">

to this

<div class="ds-1col node node-page clearfix clearfix view-mode-full content clearfix" typeof="foaf:Document" about="/node/1">

Thanks

  • What is the Drupal version and which theme you are using? I noticed that there are 3 clearfix in class. It is weird to me. – Jimmy Ko Jul 21 '16 at 22:17
  • Probably by creating a DS custom template – No Sssweat Jul 21 '16 at 22:19
  • @JimmyKo : is a my custom theme based on basic theme "Tao". For the 3 clearfix I've solved, it was a my mistake. – kb8 Jul 21 '16 at 22:21
  • @NoSssweat : the issue is present also without a DS custom template – kb8 Jul 21 '16 at 22:23
  • It seems like you would have to hack DS, an alternative would be to remove it using jQuery. – No Sssweat Jul 21 '16 at 22:32
2

Below code is quoted from template.php of Tao.

/**
 * Implementation of preprocess_node().
 */
function tao_preprocess_node(&$vars) {
  $vars['hook'] = 'node';

  $vars['classes_array'][] = 'clearfix';

  $vars['attributes_array']['id'] = "node-{$vars['node']->nid}";

  ...

The ID is added by this line.

$vars['attributes_array']['id'] = "node-{$vars['node']->nid}";

You can override it by implementing the same hook function in template.php of your custom child theme.

/**
 * Implements hook_preprocess_node().
 */
function mytheme_preprocess_node(&$vars) {
  unset($vars['attributes_array']['id']);
}
  • 1
    Is this assuming he only has 1 div id on the node? – No Sssweat Jul 21 '16 at 22:56
  • 2
    According to the node.tpl.php, I think yes... – Jimmy Ko Jul 21 '16 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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