3

I bring this question because I am not able to find the answer in anywhere, my apologies if it is a repeated one.

I have a Profile 2 type "curriculum_vitae", that I use to gather jobseekers CV.

I have all the Jobseeker's CVs available for anonymous users which is working fine. My question how to theme the jobseeker's CV page "The page that will display to anonymous user once they click at the jobseeker profile".

I have a page named "profile2--curriculum_vitae.tpl.php" located at "\templates\profile2--curriculum_vitae.tpl.php".

I want to theme every single field of curriculum_vitae profile.

For example :

<div class="container">
<div class="row">
<table class="table table-user-information">
<tbody>
<tr>
<td><strong>Email:</strong></td>
<td>Here I want to print jobseeker's email in here, the filed machine name is "field_cv_email_address"</td>
</tr>
</tbody>
</table>
</div>
</div>

3 Answers 3

1
+50

Your template needs to be:

<div class="container">
  <div class="row">
    <table class="table table-user-information">
    <tbody>
    <tr>
      <td><strong>Email:</strong></td>
      <td><?php print render($content['field_cv_email_address']); ?></td>
    </tr>
    </tbody>
    </table>
  </div>
</div>
2
  • Thanks for that, One last question. I want to use a condition to display user's personal information. I have a radio in p2 "field_cv_share_my_personal_info" with values public, private. Now if it was node I could have used "$field_items = 'field_get_items('node', $node, 'field_cv_share_my_personal_info'); <?php if ($field_items[0]['value']=='Public') { print render(email) } else{ print "Sorry not accessible to public"; } ?> '"
    – Yama
    Jul 15, 2015 at 13:32
  • You should be able to use similar code, the first argument to field_get_items should be 'profile' and the second argument will probably be $user or $profile Jul 15, 2015 at 14:38
2

You can create a View of page display of type Profile types

enter image description here

Then in this View add curriculum_vitae as Relationships, It causes the fields of curriculum_vitae profile be added to the Fields.

Now create a Contextual Filter of any field you want (it might be name, ID, ...).

So you can easily theme this View to display the information of the selected user. If the View name be profile, Then using views-view-fields--profile--page.tpl.php you can theme the output.

1

Same Colin Shipton's answer and more for your question. Code in file profile2.tpl.php

<?php
$share = field_get_items('profile2', $profile2, 'field_cv_share_my_personal_info');
//dpm($share);
$email = $share[0]['value'] == 'YourValue'
  ? $content['field_cv_email_address']
  : t('Sorry not accessible to public"');
?>
<div class="container">
  <div class="row">
    <table class="table table-user-information">
      <tbody>
      <tr>
        <td><strong>Email:</strong></td>
        <td><?php print $email; ?></td>
      </tr>
      </tbody>
    </table>
  </div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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