0

I have this core profile field in Drupal7: profile-curso-basico. I want it to be shown in the user´s profile only if the field has information in it (it´s a deprecated field, but some old users have data in it, and migrate modules didn´t import it properly, because it´s a hardcoded list).

I´m using panels, token and Display Suite modules. At the profile page, I have this panel with a special coded DS field, that has dinamic information using tokens.

If I just paste: Mi Curso: %user:profile-curso-basico I get the field information properly, but I want to show it only if profile-curso-basico field isn´t empty.

So I thought of this (the input type is PHP, so I can paste some php code):

<?php if (!empty(%user:profile-curso-basico)): ?>
%user:profile-curso-basico
<?php endif; ?>

And I´ve got this error:

Parse error: syntax error, unexpected T_LNUMBER, expecting T_PAAMAYIM_NEKUDOTAYIM in /home/liga/public_html/modules/php/php.module(80) : eval()'d code on line 9

What´s wrong with that snippet? Maybe I shouldn´t add tokens into (!empty( )) ? How may I change that in order to work? Thanks!!

1
  • Drupal tokens are not valid PHP-code. Your code simply isn't valid. – Letharion Mar 17 '13 at 17:55
0

You must refer to the actual field in your snippet. Try something like:

<?php 
global $user;    
if (isset($user->profile-curso-basico[LANGUAGE_NONE][0]['value'])) {
  echo $user->profile-curso-basico[LANGUAGE_NONE][0]['value'];
} ?>

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.