Hi,

When I first open the template to edit it, the only code displayed is a print $body even if all my fields are present in the body variables.

Is this a normal behaviour? I believed the textfield would show some html code with php for variables but not just a print $body line.

I think I missed something but I don't see what. I tried to use alpha and dev version, deleting conemplate tables between these tests for the same result.

Comments

glide’s picture

Was there any resolution on this, I'm seeing the same thing, the UI just shows print $body in the template area, not all the usual php and html goodness I was able to edit back in D6

dgtlmoon’s picture

Status:Active» Postponed (maintainer needs more info)

I'm not sure what you mean, current D6 and D7 versions all just give you the

<?php
 
print $body
?>

If you click on a field in the 'Body Variables' textarea it will insert that variable, is that what you mean?

glide’s picture

Category:bug» support
Status:Needs review» Postponed (maintainer needs more info)

You seem to have answered my question in that this is the expected output, but I was used to how in showed back in ver 6.x-1.2 as an example

example of OLD RSS template:

<div class="field field-type-filefield field-field-staff-pic">
  <h3 class="field-label">Staff Picture</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_staff_pic[0]['view'] ?></div>
  </div>
</div>
.........................

example of NEW RSS template:

<?php print $body ?>

If the "new" way is to start with an essenially blank slate, then it is working as expected, just not what I was expecting. Before I could just do a few edits and get things like I wanted them, now I have to recontruct the entire page from scratch.

dgtlmoon’s picture

Aah i see what you mean, it used to render the whole content type out, right? (i've just picked up maintenance of this module so hang in there.. )

dgtlmoon’s picture

Category:support» bug
Status:Postponed (maintainer needs more info)» Active

this is going back to a bug, because the D6 worked and users would expect the D7 to behave much the same

dgtlmoon’s picture

Wonder why, git blame says this stuff has not changed in a long time, will have a look into it

b6fed0eb (James R Glasgow 2008-02-28 18:16:27 +0000 256)   if ($default = contemplate_cck_get_fields($type)) {
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 257)     $default_teaser = $default_body = $default;
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 258)   }
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 259)   else {
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 260)     $default_teaser = "<?php print \$teaser ?>\n";
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 261)     $default_body = "<?php print \$body ?>\n";
^b1e6c10 (Jeff Robbins    2006-05-16 19:38:13 +0000 262)   }
glide’s picture

thats correct, or at least what used to be correct...

dgtlmoon’s picture

Also, are you editing a CCK field or something not from CCK?

glide’s picture

Im editing a custom CCK content type.

But i see the same behavior even if I pick one of the standard default types.

dgtlmoon’s picture

OK yes, got it, D6 uses CCK and D7 uses fields, so contemplate_cck_get_fields(...) needs to refactored

dgtlmoon’s picture

Status:Active» Needs review

try latest dev

glide’s picture

Latest dev wouldnt show up in the modules list after i installed it. I did notice the rc3 was updated last night as well, so tried that and it seems to be working. Did you change both?

dgtlmoon’s picture

Category:support» bug
Status:Postponed (maintainer needs more info)» Needs review

Yes, but theres a new issue with some CCK fields, so it still requires some work.

latest dev output in the template is (for image)

<div class="field field-type-image-image field-field-test">
  <h3 class="field-label">test</h3>
  <div class="field-items">
      <div class="field-item"><?php print render( $fields['field_test'] ); ?></div>
  </div>
</div>

cant figure out how to get any finer rendering of the fields just yet, try current dev and see how it works for you

dgtlmoon’s picture

dont forget to hit [delete] on the template to rebuild it

glide’s picture

switched to dev, text fields are working, but as you said image links are still mucked up. getting:

<div class="field field-type-image-image field-field-staff-pic">
  <h3 class="field-label">Staff Picture</h3>
  <div class="field-items">
      <div class="field-item"><?php print $node->field_staff_pic[$node->language][0]['safe_value']; ?></div>
  </div>
</div>

Which then generates:

<div class="field field-type-image-image field-field-staff-pic">
  <h3 class="field-label">Staff Picture</h3>
  <div class="field-items">
      <div class="field-item"></div>
  </div>
</div>

Which clearly doesn't output a picture.

The variables section also isnt giving anything more than

$node->field_staff_pic (array)

Where my outdated D6 version gives

$node->field_staff_pic (array)

    $node->field_staff_pic[0] (array)

        $node->field_staff_pic[0]['fid']
            87
        $node->field_staff_pic[0]['uid']
            1
        $node->field_staff_pic[0]['filename']
            jxu.jpg
        $node->field_staff_pic[0]['filepath']
            sites/default/files/filename.jpg
        $node->field_staff_pic[0]['filemime']
            image/jpeg
        $node->field_staff_pic[0]['filesize']
            4511
        $node->field_staff_pic[0]['status']
            1
        $node->field_staff_pic[0]['timestamp']
            1305658370
        $node->field_staff_pic[0]['list']
            1
        $node->field_staff_pic[0]['data'] (array)

            $node->field_staff_pic[0]['data']['alt']
            $node->field_staff_pic[0]['data']['title']

        $node->field_staff_pic[0]['nid']
            85
        $node->field_staff_pic[0]['view']
            <img class="imagefield imagefield-field_staff_pic" width="156" height="200" alt="" src="http://hostname.example.com/system/files/filename.jpg?1305658370" />

$node->field_staff_current (array)

    $node->field_staff_current[0] (array)

        $node->field_staff_current[0]['value'] **
            Current
        $node->field_staff_current[0]['safe']
            Current
        $node->field_staff_current[0]['view']
            Current

dgtlmoon’s picture

images cant be handled the same way, because $node does not actually contain the image path. it contains the resource, so i'm not sure what todo, ideas?

dgtlmoon’s picture

Field theming has some layer of abstraction, it relies on $variables not $node

function theme_field($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':&nbsp;</div>';
  }

  // Render the items.
  $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
  }
  $output .= '</div>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';

  return $output;
}

dgtlmoon’s picture

So basically, it all comes down to the fact that

<?php print $node->field_staff_pic[$node->language][0]['safe_value']; ?>

is not available in the $node anymore because they leave the theming until the last minute in D7

so I think what we need todo is add some extra values, or make an extra obejct available as well as $node

so you have

$node - for general node stuff
$content - for content rendered, like field $content->field_staff_pic[$node->language][0]['safe_value'];

dgtlmoon’s picture

D7 is also waiting for CCK tokens to be working #691078: Field tokens

using tokens would be nice too

glide’s picture

yeah it looks like this might be about as far as things go until a couple more things open up. Thanks for your updates though. They help enormously.

Danny Englander’s picture

Subscribing, having the same issue.