I posted this on the main drupal theme development forum with no response so i thought i might try my portland buddies...
I am developing a theme for a site that has multiple listings. The site had a landing page with a summary menu produced by creating a view with an argument of city (organizes listings by city). Upon clicking on the city, the user sees, for example, all the restaurants of that particular city. Upon clicking on the restaurant name, the user sees the node page with the body output of the all fields created using CCK.
these links show the process:
http://vc.andreaburton.com/eat
http://vc.andreaburton.com/pittsboro
http://vc.andreaburton.com/node/194
I am trying to figure out the best way to theme the node pages. There is not data for every single field in every single node. I have created a custom node-eat.tpl.php to style this page but the code for the field shows up even if there is no data. I have attached the code below. (if you look at the source code of http://vc.andreaburton.com/node/194 you will see an empty <h3></h3>
that is placed there for a tagline. this node does not have a tagline thus no data appears. it just seems bobo to have empty html tags in a template with no data in them.)
I have even tried contemplate but it seems to create very similar code output.
I have had some success creating a content-field.tpl.php file for each field. The code here knows when to not show a field if there is no data using !$field_empty
variable. but with a site with hundreds of fields, it seems a little crazy to make a separate file for each field.
is there any code to basically say, hey drupal, im in the node.tpl.php, if there is no data for any of the CCK fields don't output it in the theme?
also, im wondering if there is any way i can put the detail page out as a view. I was able to create the view with the summary ascending using the city as an argument and creating the table view with the title, city and website, (http://vc.andreaburton.com/pittsboro) but when i went to create a second argument (i was trying to go with title name), i got stuck when i was trying to have the title of a node link to a view created by an argument. please no judgement here, i am swimming in new territory so i may be talking crazy. i figured i could them style the views theme and it would filter out the fields that had no data. but it seems contradictory because shouldn't i just use the node pages and style those instead of creating a view of the detail page?
thanks for any help. im really trying to wrap my head around the proper way to do this.
thanks!
andrea b.
code from the node-eat.tpl.php
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"><div class="node-inner" id="detail-page">
<?php if (!$page): ?>
<h2 class="title">
<a href="<?php print $node_url; ?>" title="<?php print $title ?>"><?php print $title; ?></a>
</h2>
<?php endif; ?>
<?php if ($unpublished): ?>
<div class="unpublished"><?php print t('Unpublished'); ?></div>
<?php endif; ?>
<div class="content">
<div id="column-1">
<h3><?php echo $node->field_shortdesc[0]['view'];?></h3>
<ul>
<li><strong><?php echo $node->field_phone[0]['view'];?></strong></li>
<li><a href="mailto:<?php echo $node->field_email[0]['value'];?>"><?php echo $node->field_email[0]['view'];?></a></li>
<li><a href="<?php echo $node->field_website[0]['value'];?>">View Website</a></li>
</ul>
<ul>
<li><strong>Address:</strong> <?php echo $node->field_address[0]['view'];?>, <?php echo $node->field_city[0]['view'];?>, <?php echo $node->field_zip[0]['view'];?></li>
<li><strong>Mailing Address:</strong> <?php echo $node->field_mailingaddress[0]['view'];?>, <?php echo $node->field_city[0]['view'];?>, <?php echo $node->field_zip[0]['view'];?></li>
</ul>
<p><?php print $node->content['body']['#value'];?></p>
<h4>Amenities</h4>
<p><?php echo $node->field_amenitiesnotes[0]['view'];?></div>
<?php print $links; ?>
<div id="column-2">
<span><?php echo theme('imagecache', 'node_image', $node->field_nodeimage[0]['filepath'], $node->title, $node->title, array('class' => 'node-image')); ?></span>
</div>
</div>
<?php if ($terms): ?>
<div class="meta">
<?php if ($terms): ?>
<div class="terms terms-inline"><?php print t(' in ') . $terms; ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
</div></div> <!-- /node-inner, /node -->