6

I'm using Display Suite module to create custom fields.

I've to add a code field (php), that calls a function that has $nid as argument. I've added this field to node entity but I can't understand if there are variables available on this field.

Adding a php field I've a textare where I can add php code.ù I've a custom functions that retuns html and require a nid as argument.

so in my custom field I should have something like:

<?php
print my_function($nid);
?>

The problem is that I don't know where find the $nid: $object? $node? $entity? $context?

This field is added on an node entity.

8

You can get access to the node via the $entity variable within the "Field code" text area.

This will only work for the Display Suite "Code Field". If you are using Display Suite 7.x-2.x, you'll have to enable the "Display Suite Format" module.

If anything is setup properly, you should see this help text below the "Field code" text area:

You may post Display Suite code. You should include tags when using PHP. The $entity object is available.

  • In my code field there isn't $entity variable.. there is an alternative? – Shyghar Sep 15 '14 at 13:23

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