I18N Search - Result Tables
This is an example of a (sortable) result table instead of a list with I18N Search:
Name | Description | Platform | License |
---|---|---|---|
jEasyORM | A simple ORM for Java, which does not need configuration files. | Platform-independent | GNU GPLv3 |
phpEasyVCS | A great VCS which only uses PHP and no DB. Nothing else. | Platform-independent | GNU GPLv3 |
All you need for this is to create a component (e.g. named searchresults-oss) like this:
<?php global $language; $result = return_i18n_search_results('_special_software',null,0,10000,null,$language); ?> <table class="sortable"> <thead> <tr> <th>Name</th> <th>Description</th> <th>Platform</th> <th>License</th> </tr> </thead> <tbody> <?php foreach ($result['results'] as $item) { ?> <tr> <td style="white-space:nowrap;"> <a href="<?php echo $item->link; ?>"> <?php echo htmlspecialchars($item->title, ENT_NOQUOTES); ?> </a> </td> <td><?php echo htmlspecialchars($item->summary); ?></td> <td><?php echo htmlspecialchars($item->platform); ?></td> <td style="white-space:nowrap;"><?php echo htmlspecialchars($item->license); ?></td> </tr> <?php } ?> </tbody> </table>
First a search is made (here for all pages with tag _special_software) and then the table is output, where for each row the values of the current result item, i.e. the fields of the result page are used. Of you can only do this, if you have these fields, by using either the I18N Custom Fields plugin or the I18N Special Pages plugin.
Then - using the DynPages plugin - you can embed this table in your page like this:
{% searchresults-oss %}
You can even further limit the content of the table by passing search words as parameters, like here (searching for ORM).
If you want to make this table sortable, you can e.g. use the Tablesorter jQuery plugin and include the following code either in your template or the above component:
<script type="text/javascript" src="<?php get_theme_url(); ?>/jquery.tablesorter.min.js"></script> <script type="text/javascript"> $(function() { $(".sortable").tablesorter(); }); </script>
To show the user that the table is sortable, some CSS like the following can be used:
#content table th.header { background-image: url("images/sort.gif"); background-position: right center; background-repeat: no-repeat; cursor: pointer; } #content table th.headerSortUp { background-image: url("images/asc.gif"); } #content table th.headerSortDown { background-image: url("images/desc.gif"); }