[support] token in code field in Display suite
Bert Van Kets
bertvankets at gmail.com
Sat Jul 26 11:45:11 UTC 2014
I got the token reference from the token list. You can request that link
at the bottom of the page where you define the code field in display suite.
I found a way around this problem for now. It's kind of a dirty hack.
I used $entity->field_project_type['und'][0]['tid'] in my condition. A
quick dpm gave me the value of the tid. Ideally I should request the
taxonomy term using the tid and get the value from that.
I got a solution for now. I'll have to dig into using tokens a bit
further later.
Here's the code I used
<?php
if ($entity->field_project_type['und'][0]['tid'] === '12') {
print "Project " . "[node:title]";
} else {
print "[node:title]";
}
?>
Bert
On 26/07/14 07:31, Paul Rijke wrote:
> Could it be that de field referenced is wrong?
>
> I am no php programmar, but in examples I see
> $node->field_project_type used
>
>
> 2014-07-26 0:55 GMT+02:00 Don <donald at fane.com <mailto:donald at fane.com>>:
>
> Doesn't look like ' [node:field_project_type] ' has any real value
> in the if() statement.
>
> -Don-
>
>
> On 7/25/2014 6:36 PM, Bert Van Kets wrote:
>> Hi all,
>>
>> I need to change the title of a node depending on the value of the field
>> field_project_type. I created a "PHP code" code field in display suite
>> and added the following code:
>>
>> <?php if ([node:field_project_type] == 'Project') { ?>
>> Project [node:title]
>> <?php } else { ?>
>> [node:title]
>> <?php } ?>
>>
>> However, I get the following error:
>>
>> Parse error: syntax error, unexpected ':', expecting ']' in
>> /var/www/wallfish/modules/php/php.module(80) : eval()'d code on line 1
>>
>> What am I doing wrong?
>> I can't find any correct way to get the value of that field through a token.
>>
>> Thanks.
>>
>> Bert
>
>
> --
>
> --
> -Don Pickerel-
> Fane Software
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20140726/5d131e20/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 18361 bytes
Desc: not available
Url : http://lists.drupal.org/pipermail/support/attachments/20140726/5d131e20/attachment-0001.png
More information about the support
mailing list