Drupal 6 CCK Field Not Showing
In Drupal 6, I added a custom field to a custom content type.
The name is: "field_publishedin"
I then added data into that field for some sample articles.
In the view for it, I added that field as well.
On the page that renders it I added the code to show the field as well:
<div class="press-content">
<div class="family-news">
<?php foreach($rows as $row): ?>
<div class="news">
<div class="data">Posted on <a href="<?php print url('news/'.$row['created_1']) ?>"> <?php print $row['created'] ?></a> </div><!--DATA-->
<h4><?php print $row['title'] ?><span><?php print $row['field_publishedin_value']; ?></span></h4>
</div><!--NEWS-->
<?php endforeach ?>
</div>
</div>
So the code I added is <span><?php print $row['field_publishedin_value']; ?></span>
since according to the view when using in a template you are suppose to add "_valu开发者_JAVA百科e".
However, I clicked rescan templates, emptied the drupal cache but that new code still does not render on the page.
When I add this to the page: <?php print '<pre>' . htmlentities(print_r($rows, 1)) . '</pre>'; ?>
and it outputs the possible array values it does not show, "field_publishedin_value" so it seems like the template doesnt know that field exists even though its in the view. Help?
install the devel module, and in to *.tpl.php, place:
<?php
dpm($fields); // if views
// or dpm($node); if it's a node or page.tpl.php
// of if you don't know, dpm(get_defined_vars());
?>
Also, if this is views, the template you should be using is the views-view-fields.tpl.php. Note the PLURAL fields.
Joe
精彩评论