Support » Fixing WordPress » Display archive data in a sortable table format

  • I would like to be able to display post title, rating and a permalink in a sortable table format whenever a user clicks on a specific category. Does anyone know how to do this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • There might be a plugin that creates sortable tables that might be useful. Like this one:
    wp-table

    But that isn’t very current…

    I have seen this one implemented with WP:
    http://www.phatfusion.net/sortabletable/

    Probably take a little work, but it is nice.

    Thread Starter deserturchin

    (@deserturchin)

    The sortable feature isn’t my main issue. I think I can figure that out. I am not sure how to change the archive.php to display the data in a table rather than the default method. Any help on this issue would be greatly appreciated.

    me to:

    I have great difficulty using <table> in post. For example if I use fckeditor to creative the table.

    <table width=”200″ cellspacing=”1″ cellpadding=”1″ border=”1″>
    <tbody>
    <tr>
    <td>Text 1</td>
    <td>Text 2</td>
    </tr>
    <tr>
    <td> Text 3</td>
    <td>Text 4</td>
    </tr>
    <tr>
    <td> Text 5</td>
    <td> Text 6</td>
    </tr>
    </tbody>
    </table>

    When I look at the post as viewed it looks fine. But I if I look at it as search results or as archives the <table> is messed up. I haven’t fund a theme there can’t view this probably.

    Is there a way how a post whatever appears on the same way?

    I’ve just figured it out.

    You can see the demo here: Demo

    There are some problem left, the number of pageview & comment are not correctly, the javascript doesn’t run.

    Here is the code I used…

    <?php if (have_posts()) :$post = $posts[0]; while (have_posts()) : the_post(); ?>
    <center><h2><?php the_title(); ?></h2></center>
    <center><?php the_content();?></center>
    		<div id="example">
    		  <table id="myTable" cellpadding="0" cellpadding="0">
    		  	<thead>
    				<th axis="number">ID</th>
    				<th axis="string">Title</th>
    				<th axis="string">Pageview</th>
    				<th axis="string">Comment</th>
    				<th axis="category">Category</th>
    				<th axis="date">Date</th>
    			</thead>
    			<tbody>
    				<?php $myposts = get_posts('numberposts=-1;offset=0');foreach($myposts as $post) :?>
    				<? $stt = $stt + 1; ?>
    				<tr id="<?php $stt ?>">
    					<td align="center"><?php echo $stt ?></td>
    					<td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>
    					<td align="center"><a href="<?php the_permalink(); ?>"><?php the_views(); ?></a></td>
    					<td align="center"><a href="<?php the_permalink(); ?>#comments"><?php comments_number('0','1','%');?></a></td>
    					<td><?php the_category(', ') ?></td>
    					<td align="center"><?php the_time('d/m/Y') ?></td>
    				</tr>
    				<?php endforeach; ?>
    			</tbody>
    			<tfoot>
    				<tr>
    					<td></td>
    					<td></td>
    					<td></td>
    					<td></td>
    					<td></td>
    					<td></td>
    				</tr>
    			</tfoot>
    		  </table>
    		</div>
    <?php endwhile; endif; ?>

    ah, add these code after tag </ table > and you will make it “sortable” ^^

    <script type="text/javascript">
    			var myTable = {};
    			window.addEvent('domready', function(){
    				myTable = new sortableTable('myTable', {overCls: 'over', onClick: function(){alert(this.id)}});
    			});
    		</script>

    After one day…. I’ve made it completely. You can see the demo here. I’ll write an entry for this work later to give more detail on the code.

    Hi Mr Live

    The demo you posted no longer works..do you have another site we could look at? I am interested in doing the exact same thing but with little luck so far.

    Thanks, Balthazar

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display archive data in a sortable table format’ is closed to new replies.