I wanted to create an address book, and all I could find was how you just use CCK fields and Views.
While that did eventually work, it would have helped to have a few of the steps and problems listed.
So, here is what I did:
Install CCK and Views (and probalby the Views Bonus Pack for CSV import)
Create Content Type: AddrBookEntry
Create Fields
First Name
Last Name
etc...
There are quite a few CCK modules to add special field
types like ZipCode, Email address, etc.. (Just note that certain of the
fields don't seem to work with the CSV import. I hit that with ZipCode and Date fields.)
Create a couple of "AddrBookEntry" content items (makes testing the view easier)
Create a View (I made a Table view of all the fields, and several Displays in
that view for various sub-sets of the list.)
Then Import your CSV data. (Administer-Content Management-Import Content)
Note: Use the Views Bonus Pack so you can export the Address book to a CSV
file. How to do that is non-obvious, and only documented in a bug report:
http://drupal.org/node/334054
I also used the "Content Template" module so I could format the AddrBookEntry
view into a more legible format. If you are using something like FCKEditor
for WYSIWYG editing, you'll probably want to disable it for template editing.
The path to disable is: admin/content/node-type/*/template
My template looks like this:
<div class="field field-type-text field-field-mem-status">
<div class="field-items">
<div class="field-item"><b>Status: </b><?php print $node->field_mem_status[0]['view'] ?></div>
</div>
</div>
<div class="field field-type-date field-field-mem-expire">
<div class="field-items">
<div class="field-item"><b>Expiration: </b><?php print $node->field_mem_expire[0]['view'] ?></div>
</div>
</div>
<br />
<div class="field field-type-text field-items field-item">
<?php print $node->field_mem_fname[0]['view'] ?>
<?php print $node->field_mem_mi[0]['view'] ?>
<?php print $node->field_mem_lname[0]['view'] ?>
<br />
<?php print $node->field_mem_addr1[0]['view'] ?>
<br />
<?php
if ($node->field_mem_addr2[0]['value'] != '') {
print $node->field_mem_addr2[0]['view'];
print '<br />';
}
?>
<?php print $node->field_mem_city[0]['view'] ?>,
<?php print $node->field_mem_state[0]['view'] ?>.
<?php print $node->field_mem_zip[0]['view'] ?>
<?php print $node->field_mem_country[0]['view'] ?>
<br />
<br />
</div>
<br />
<table>
<tr class="field field-type-email field-field-mem-email">
<span class="field-items field-item">
<td><b>Email: </b></td>
<td><?php print $node->field_mem_email[0]['view'] ?></td>
</span>
</tr>
<tr class="field field-type-ca-phone field-field-mem-homephone">
<span class="field-items field-item">
<td><b>Home Phone: </b></td>
<td><?php print $node->field_mem_homephone[0]['view'] ?></td>
</span>
</tr>
<tr class="field field-type-ca-phone field-field-mem-cellphone">
<span class="field-items field-item">
<td><b>Cell Phone: </b></td>
<td><?php print $node->field_mem_cellphone[0]['view'] ?></td>
</span>
</tr>
<div class="field field-type-date field-field-mem-work">
<span class="field-items field-item">
<td class="field-item"><b>Work: </b></td>
<td><?php print $node->field_mem_work[0]['view'] ?></td>
</span>
</tr>
</table>The "CSS Injector" module lets you define your own CSS classes without having
to create Yet Another file in your file system. (I ended up not using it
here, but could have.)
Since I didn't like the various fields wrapping to multiple lines in the Table
view, I ended up creating "views-view-field--.tpl.php" in
sites/all/themes// . The file contains:
<?php
print $output;
?>The hardest part has been getting the Edit page for AddrBookEntry to be even
remotely decently formatted. All the defaults want to put the Field Name
on a separate line from the Field value, which makes the page WAY too long.
The relevant CSS classe seems to be "form-item" for text fields.
I still haven't figured out a way to override this reliably. (I hacked a
change in that worked with Garland, but doesn't work with Marinelli.)
Comments
Have you seen the Addresses
Have you seen the Addresses module? http://drupal.org/project/addresses
Actually, yes. As far as I
Actually, yes.
As far as I can tell, it creates an address book for the site users. I need an address book that is unrelated to site users.
I've also noticed that it is still under flux, and appears to be not stable yet.