The following snippet works with the modified D7 API:

<!-- start snippet -->
<p>Who would you like to contact?</p>
<?php
  $result = db_query('SELECT * FROM {contact} ORDER BY weight, category');
  print '<div id="contact-list">';
  print '<div class="item-list"><ul>';
  foreach ($result as $contact) {
    $cleanurl = str_replace(' ', '_' ,$contact->category);
    print '<li>'. l($contact->category , 'contact/'. $cleanurl) .'</li>';
  }
  print '</div>';
  print '</div>';
?>
<!-- end snippet -->

Comments

behindthepage’s picture

Thanks

Shadlington’s picture

So where would I put this to get it to work?

behindthepage’s picture

Hi Shadlington,

This snippet can be put in a page and customised to generate links to the unique contact forms.
I would use "-" as the space replacement or have no space replacement

<!-- start snippet -->
<p>Who would you like to contact?</p>
<?php
  $result = db_query('SELECT * FROM {contact} ORDER BY weight, category');
  print '<div id="contact-list">';
  print '<div class="item-list"><ul>';
  foreach ($result as $contact) {
    // space replacement
    $cleanurl = str_replace(' ', '-' ,$contact->category);
    print '<li>'. l($contact->category , 'contact/'. $cleanurl) .'</li>';
    // or if you don't want to replace the spaces with anything replace the prior 2 lines with this
    // print '<li>'. l($contact->category , 'contact/'. $contact->category) .'</li>';
  }
  print '</div>';
  print '</div>';
?>
<!-- end snippet -->

You can also add the page info to the above snippet with this:
<?php print $contact->page_info ?>

Regards
Geoff

behindthepage’s picture

Status: Active » Closed (fixed)