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.
Hello,
I was wondering if someone could help me with the code to check if content profile (named "profile") exists on the page.tpl.php
I am wanting to print a link for "Create Profile" if content profile does not exist, and print a link for "Edit Profile" if the content profile exists.
Many thanks!
Comments
Comment #1
YK85 CreditAttribution: YK85 commentedwould anyone be able to help with this?
im not able to find this in the documentation anywhere
thanks!
Comment #2
kpv CreditAttribution: kpv commentedNot sure about $node->language but it works.
For more details see: http://drupalcontrib.org/api/function/content_profile_profile_exists/6
http://drupal.org/node/49768
http://api.drupal.org/api/global/language
Comment #3
texas-bronius CreditAttribution: texas-bronius commentedThanks for that snippet. A step further is to link right into the authenticated user's edit or create Content Profile form:
Comment #4
YK85 CreditAttribution: YK85 commentedThanks for sharing!
I was wondering what the $node->language = 'en' is needed for?
Also, I found that 'user/'. $user->uid .'/edit/profile' doesn't work, but 'user/'. $user->uid .'/profile/profile' does work.
Is there a way to change the url of the profile edit page to '/profile/edit' without the 'user/'. $user->uid . on the site url?
Comment #5
krisis CreditAttribution: krisis commentedThe language part is only used in the query for translation purposes. When the translation module is found and the $node->type (in this case content type 'profile') allows for duplicating in different languages, the query will explicitly search for the user profile in that language.