Hi -- I am using real name, cck, and content profile -- and two fields for the real name: one for the first name and another for the last name. In my user profile (e.g., /user/14 ), my first name is displayed on top of my last name and I want it to be on one line. So, I decided that I would use content template (contemplate). This is my first time using it. I'm hoping someone will please let me know if the way I'm modifying content template is correct/best practice? I don't do/know Php. Thank you so much in advance.

Original code in body template (Truncated)

<div class="field field-type-text field-field-biofirstname">
  <h3 class="field-label">First name</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_biofirstname[0]['view'] ?></div>
  </div>
</div>

<div class="field field-type-text field-field-biolastname">
  <h3 class="field-label">Last name</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_biolastname[0]['view'] ?></div>
  </div>
</div>

<div class="field field-type-text field-field-biotitle">
  <h3 class="field-label">Title</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_biotitle[0]['view'] ?></div>
  </div>
</div>

Changed code in body template

<div class="field field-type-text field-field-biofirstname">
  <h3 class="field-label">First name</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_biofirstname[0]['view'] ?><?php print $node->field_biolastname[0]['view'] ?></div>
  </div>
</div>

<div class="field field-type-text field-field-biotitle">
  <h3 class="field-label">Title</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_biotitle[0]['view'] ?></div>
  </div>
</div>

Comments

vm’s picture

if those are the names of your fields and they are working the answer is yes.

However, I'd put them in their own custom tpl.php files rather than storing them in the database with contemplate. Contemplate is good for looking in the variables and showing you what is going on though many have made the switch to devel.module which offers more powerful tools.

I'd not expect contemplate to make it to D7 based on the popularity of devel.module

nwsunni’s picture

Hi --

I just looked at the output and, it kinda worked. But it destroyed my group headings that I had entered in the manage fields page. And it also put the label first name in the output when I had hid it. And, to top it off, title (see below) was on the same line as the actual title and now it's above it. So, I guess I screwed up but not sure how. But what I did get -- FINALLY lol --- was first name last name on the same line. Oh sheesh.. I fix one thing and mess up the rest. aaaahhhh

First name
Gary Johnson
Title
Associate professor of geology and geologic engineering
Unit
Geological Sciences Department
Office
Idaho Falls
Bio

nwsunni’s picture

Ok. I think I get why. Contemplate totally takes over, ignoring all the settings elsewhere. Hmmm.

When I started this, I thought that real name would put the name on one line in the profile when using name pattern but it displays it correct everywhere except for use profile page. So, that's what has caused me to fuss with this. I did look at the user-profile.tpl.php and thought about modifying it but it just has the one variable that prints...everything is wrapped up inside of it, it appears. (note: not a programmer...so lots of absorbing guessing and hesitancy goes on with me). Contemplate looked easier for a themer.

But, I'm open to trying. So, I guess I remove that variable: user_profile and use the other variable: profile. It says that is: Keyed array of profile categories and their items or other data. No idea what that means.

Or, boy, do I just copy/paste from the body template into the user-profile.tpl.php??