I want to do what the nodeteaser module does (make a field for teaser that is completely separate from body) using CCK and Contemplate instead. I'm almost there.
My only problem now is that when the field_teaser field is empty, nothing shows up at all for the teaser. I'd like it to behave like Drupal does by default, authomically create the teaser based on the setting at /admin/content/node-settings. (The nodeteaser module does this very well -- it does other things poorly).
Here is the code that is on the Contemplate's template creation admin page at:
/content/types/content_type_name/template. It works great when a teaser exists.
<div class="field field-type-text field-field-teaser">
<div class="field-items">
<?php foreach ((array)$field_teaser as $item) { ?>
<div class="field-item"><?php print $item['view'] ?></div>
<?php } ?>
</div>
</div>Here is how I tried to change that code in my attempt to handle an empty field_teaser situation:
<?php if ($field_teaser !="") { ?>
<div class="field field-type-text field-field-teaser">
<h3 class="field-label">teaser</h3>
<div class="field-items">
<?php foreach ((array)$field_teaser as $item) { ?>
<div class="field-item"><?php print $item['view'] ?></div>
<?php } ?>
</div>
</div>
<?php } ?>This solution failed miserably -- I obviously don't get how this stuff works (FYI I'm a novice at PHP). That code causes the printed label "teaser" to show up when a teaser existed (but didn't print the actual teaser) -- and still nothing showed up when the field_teaser field for the node was empty.
I'd most appreciate some help. I'm sure others have faced this exact issue.
I posted this already to the general drupal forum with no response. I'm guessing (hoping) this is a better place for it.
Much thanks,
Shai