1

I need to add a Display Suite function field to a node. I set up my hook, and my field shows up and I can add it to my content type in display. However, the function isn't getting called, and it looks like it should. I stripped my code down so I can debug this. My custom function is in my .module file.

function MYMODULE_ds_fields_info($entity_type)
{

    if ($entity_type != 'node')
        return;

    $fields = array();


    $fields['splittitle'] = array(
        'title' => t('Split product title'),
        'field_type' => DS_FIELD_TYPE_FUNCTION,
        'function' => 'MYMODULE_ds_field_splittitle'
    );


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

}


function MYMODULE_ds_field_splittitle($field)
{

    return 'test';
}

1 Answer 1

1
+50

Here is the code that worked for me... My Module name is drup_custom

function drup_custom_ds_fields_info($entity_type)
{
    if ($entity_type != 'node') {
        return;
    }

    $fields = array();


    $fields['test_title'] = array(
        'title' => t('Split product title'),
        'field_type' => DS_FIELD_TYPE_FUNCTION,
        'function' => 'drup_custom_ds_field_splittitle'
    );


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

}

function drup_custom_ds_field_splittitle($field)
{
  return 'My Content';
}

Steps to follow to see results..

  • Cleared Caches
  • Enabled Layout in Content Type Settings

enter image description here

  • Now, you can see your field in disabled list

enter image description here

  • Assign the field to which ever region you would like, Save Settings

enter image description here

  • I can see the field content in Node View Page

enter image description here

1
  • Even though this was exactly what I was doing, I must not have been clearing my cache (even though I am certain I did). Anyway, it works. Thanks!
    – vintorg
    Mar 5, 2014 at 1:46

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.