Project:Content Templates (Contemplate)
Version:7.x-1.x-dev
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

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

#1

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

#2

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?

#3

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.

#4

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.. )

#5

Category:support request» bug report
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

#6

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)   }

#7

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

#8

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

#9

Im editing a custom CCK content type.

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

#10

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

#11

Status:active» needs review

try latest dev

#12

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?

#13

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

#14

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

#15

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

#16

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?

#17

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;
}

#18

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'];

#19

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

using tokens would be nice too

#20

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.

#21

Subscribing, having the same issue.

nobody click here