Sorting Listings: Difference between revisions
(→MySQL) |
(→Markup) |
||
| Line 63: | Line 63: | ||
Sortable elements are defined by the `dom.sortable_selector` property (default `tr.rec-row`). | Sortable elements are defined by the `dom.sortable_selector` property (default `tr.rec-row`). | ||
=== Default markup === | |||
<pre> | |||
| | |||
+-- <div class="listings"> | |||
| | |||
+-- <table data-po="n"> | |||
| | |||
+-- <tr> | |||
| | | |||
| +-- <th> | |||
| | | |||
| (...) | |||
| | |||
+-- <tr class="rec-row"> | |||
| | |||
(...) | |||
</pre> | |||
=== Example of alternate markup === | |||
<pre> | |||
| | |||
+-- <div class="page-content"> | |||
| | |||
+-- <table class="table" data-po="n"> | |||
| | |||
+-- <tr> | |||
| | | |||
| +-- <th> | |||
| | | |||
| (...) | |||
| | |||
+-- <tr data-rid="n"> | |||
| | |||
(...) | |||
</pre> | |||
== MySQL == | == MySQL == | ||
Revision as of 12:15, 1 March 2015
Content Properties CMS
CMS > Content Properties
- Is Sortable: checked
- Sorting URI:
/hostmgr/_ajax/utils/resort.php(default shared AJAX handler script)
JavaScript
Sorting logic is defined in littled/resort.js which is wrapped up in littled.js.
Example:
$(document).ready(function() {
/* options can be passed as first argument to resort() */
$('.listings table:first').resort();
});
PHP
/_classes/site_content/cache_class.php
Add include directives for both the parent page’s content and content filter classes:
require_once (APP_CLASS_DIR."site_content/press_class.php"); require_once (APP_CLASS_DIR."site_filters/press_filters_class.php");
Update the set_filters() routine to include the filter class representing the page’s content type.
/_classes/site_content/cache_class.php
Potentially no changes need to be made to this class on a content-type-by-content-type basis as long as the default action for all content types is
if ($this->filters instanceof filters_collection_class) {
$this->filters->parse_filters();
$this->filters->page_len->value = null; /* get all available records */
}
If some other action needs to be taken for a specific content type then a new case would need to be created in the retrieve_section_properties() routine.
Paging is handled with
include (COMMON_TEMPLATE_DIR."framework/navigation/listings_page_links.php");
Markup
Listings container is stored in dom.listings_container, with a default value of '.listings'.
The position_offset key is defined in keys.position_offset, with a default value of 'po'. This is the position of the first record currently being displayed on a page relative to the first record in the entire set of matching listings.
When loading modal dialogs and refreshing listings content, the library looks to the data-po attribute of .listings table:first by default.
Typically the `<table> markup is in a page content template, which is wrapped in a div.listings container by the top-level page.
Sortable elements are defined by the dom.sortable_selector property (default tr.rec-row`).
Default markup
|
+-- <div class="listings">
|
+-- <table data-po="n">
|
+-- <tr>
| |
| +-- <th>
| |
| (...)
|
+-- <tr class="rec-row">
|
(...)
Example of alternate markup
|
+-- <div class="page-content">
|
+-- <table class="table" data-po="n">
|
+-- <tr>
| |
| +-- <th>
| |
| (...)
|
+-- <tr data-rid="n">
|
(...)
MySQL
Tables with sortable records must contain
- An
idcolumn containing a unique id for the record. - A
slotcolumn holding the value of the record’s position in the listings relative to all other records.