Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By sumancool.jb on
Hi friends,
I need to present node id and some field values in teaser content. Have installed DS module and activated it. Added a code field. Codes below are being used to display field values if node id is there.
$node = node_load($nid);
print $node->title;
$node needs to be replaced with node id. I need a code to display node id in code field. Is there php variables or replacement patterns available for code field in DS module ?
Comments
I believe it's $entity->nid
I believe it's $entity->nid (the comment below the box has the variable name for the object).
Thanks for the effort. The solution for my issues is..
The replacement pattern for field values were given below with a heading
Token
Didn't notice it.
The replacement for node id is [node:nid].
use node id in code field of Display suite module
hi to all,
i have the same problem...I want to use the NID to check if the current node has a certain value for a field, but I can not read it.
CODE:
if i put a fixed value for $nid var, the code work very well, but i want the current node nid.
you can help me??
Need to set Text Format to "Display Suite code", not "PHP code"
I think you may had set the Text Format dropdown to "PHP code". You need to keep it as "Display Suite code".
In "Display Suite code" mode, you have the access to the $entity object. $entity is not available in "PHP code" mode.
Thank you for that!
Thank you for that!
Développeur Drupal Freelance — Design Web & Intégration
This is more like what you
This is more like what you would want. You could perform this in preprocess and then create a custom variable to output in your tpl or this could go in the node.tpl but it's not the best option.
Set checkbox "User token" and
Set checkbox "User token" and add token [node:nid].