Features : custom page template with dynamic post table. The table is then enhanced with Jquery dataTables to add search and sort functionality.
The goal was twofold : to present data in a searchable format for visitors. To make it easy to update for the website admin with no html knowledge.
Using custom fields, the client can enter a new post in a specific category, and it will appear in the table.
Here is the code for the custom page template:
<div id="table-wrapper">
<?php query_posts('cat=3'); ?>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="food" style="width:580px"
<thead>
<tr>
<th>Location</th>
<th>Dish</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$food_location = get_post_meta( $post->ID, 'food-location', true );
$food_name = get_post_meta( $post->ID, 'food-name', true );
$food_type = get_post_meta( $post->ID, 'food-type', true );
echo '<tr>';
if ( !empty( $food_location ) ) {
echo '<td class="rightcol">' . $food_location . '</td>';
/* Add any additional code. */
}
if ( !empty( $food_name ) ) {
echo '<td class="rightcol">' . $food_name . '</td>';
/* Add any additional code. */
}
if ( !empty( $food_type ) ) {
echo '<td class="rightcol">' . $food_type . '</td>';
/* Add any additional code. */
}
echo '</tr>';
?>
You can see the demo at:
http://kingrichardsfaire.net/food-drinks/
