Album/Gallery Listings: Difference between revisions
No edit summary |
|||
| (26 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:CMS Documentation]] [[Category:Littled Libraries]] [[Category:Albums CMS]] [[Category:jQuery/AJAX]] [[Category:Web Development]] | |||
== Application == | |||
See also: [[Albums CMS Design Principles]] | |||
=== PHP === | |||
==== Album listings pages ==== | |||
* Add shared album listings template on the page, enclosed in a `<nowiki><div></nowiki>` | |||
** class `listings album-listings` | |||
** `data-tid` attribute | |||
*** Value is the `site_section` representing the listings content. | |||
*** Used for all shared AJAX scripts. | |||
** `data-p` attribute | |||
*** Value is the position of the first record on the page within the entire set of matching records. | |||
*** Used for sorting. | |||
Example: | |||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
<? include ( | <div class="listings album-listings" data-tid="<?=$filters->site_section->id->value ?>" data-p="<?=$filters->calc_rec_position()?>"> | ||
<? include (CMS_COMMON_TEMPLATE_DIR."content/albums/album_listings.php"); ?> | |||
</div> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Album details pages ==== | |||
~~TK~~ | |||
=== Javascript === | |||
==== Album listings pages ==== | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
$(document).ready(function(){ | $(document).ready(function() { | ||
/* Binds AJAX functionality to album listings elements */ | |||
$('.album-listings').galleries('bindAlbumListingsHandlers'); | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Album details pages ==== | |||
== | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
$(document).ready(function() { | |||
/* retrieves gallery content */ | |||
$('.gallery-listings').galleries('retrieveGallery'); | |||
}); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== AJAX === | |||
Assign AJAX handlers through the [[Littled Content Properties CMS|Content Properties CMS]]. | |||
* '''Listings''' `/_ajax/utils/listings.php` | |||
* '''Delete record''' `/_ajax/utils/delete_record.php` | |||
* '''Resort''' `/_ajax/utils/resort.php` | |||
* '''Update Cache''' `/_ajax/utils/update_cache.php` | |||
== PHP templates == | |||
=== Listings pages === | |||
This comes into play in album listings where there is an expand button for each of the albums which reveals the album's gallery. | |||
=== Album details and edit pages === | |||
PHP include that inserts the gallery container element into the page. It allows for either default listing content, or custom gallery listings content: | |||
<syntaxhighlight lang="php"> | |||
<? include (CMS_COMMON_TEMPLATE_DIR."forms/images/gallery_listings_container.php"); ?> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | == Image rollovers == | ||
See [[Image Rollovers (Poshytip)]] | |||
==Image lightbox== | ==Image lightbox== | ||
===JavaScript=== | === Markup === | ||
* Surround thumbnail <code><nowiki><img></nowiki></code> element in <code><nowiki><a></nowiki></code> tags with the following attributes: | |||
** <code>href="javascript:void(0)" rel="nofollow"</code> | |||
** <code>class="img-details-link"</code><br />This is the selector used to assign the <code>onclick</code> handler. | |||
** <code>data-id="[IMAGE_LINK_ID]"</code> | |||
** <code>data-tid="[GALLERY_SECTION_ID]"</code> | |||
** <code>data-op="view"</code> or <code>data-op="details"</code><br />This allows the jQuery handler to retrieve the correct AJAX script to call to retrieve the details dialog content. | |||
* Note that it doesn't seem to work having this link around the preview image. I.e. it's not immediately apparent that it's possible to click on the tooltip preview of the image to open up a full-sized version of the image in a lightbox. | |||
=== JavaScript === | |||
* <code>$('img-details-link')</code> <code>onclick</code> handler opens a dialog containing the full-resolution version of the image. | * <code>$('img-details-link')</code> <code>onclick</code> handler opens a dialog containing the full-resolution version of the image. | ||
* <code>onclick</code> handler defined in <code>$.galleries('bindAlbumListingsHandlers')</code> | * <code>onclick</code> handler defined in <code>$.galleries('bindAlbumListingsHandlers')</code> | ||
* The <code>onclick</code> handler invokes <code>$.formDialog('open', {dialogClass, 'gallery-dialog'})</code> | * The <code>onclick</code> handler invokes <code>$.formDialog('open', {dialogClass, 'gallery-dialog'})</code> | ||
=== CMS === | |||
* '''Details URI''': <code>/_ajax/images/image_details.php</code><br />This returns markup containing the full-resolution version of the image to be displayed in the lightbox dialog. | |||
===CMS=== | |||
* Details URI: <code>/_ajax/images/image_details.php</code><br />This returns markup containing the full-resolution version of the image to be displayed in the lightbox dialog. | |||
==Inserting an "add image" button== | ==Inserting an "add image" button== | ||
| Line 105: | Line 105: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
$('.add-img-btn', $p) | $('.add-img-btn', $p) | ||
. | .iconButton('addchild') | ||
.on('click', methods.editImage); /* "methods" in the context of $.galleries() */ | |||
.click | |||
</syntaxhighlight> | </syntaxhighlight> | ||
The <code>$('.add-img-btn')</code> handler is rolled into <code> | The <code>$('.add-img-btn')</code> handler is rolled into <code>$.galleries('bindGalleryHandlers')</code>. | ||
===AJAX handler script=== | ===AJAX handler script=== | ||
The handler script is determined by <code>section_properties.upload_uri</code>. If no value is found in that column, the code falls back on <code>section_properties.edit_uri</code>. | The handler script is determined by <code>section_properties.upload_uri</code>. If no value is found in that column, the code falls back on <code>section_properties.edit_uri</code>. | ||
| Line 117: | Line 115: | ||
That page will expect a combination of values to be passed in via the <code>id</code>, <code>pid</code>, and <code>tid</code> arguments. Only <code>tid</code> (type id) is strictly required. <code>pid</code> (parent id) can be null in cases when creating a new parent record and uploading images simultaneously. <code>id</code> (image link record id) can be null in cases when uploading a new image. | That page will expect a combination of values to be passed in via the <code>id</code>, <code>pid</code>, and <code>tid</code> arguments. Only <code>tid</code> (type id) is strictly required. <code>pid</code> (parent id) can be null in cases when creating a new parent record and uploading images simultaneously. <code>id</code> (image link record id) can be null in cases when uploading a new image. | ||
== | ==Pagination== | ||
===PHP=== | |||
Album listings: | |||
<syntaxhighlight lang="php"> | |||
include (COMMON_TEMPLATE_DIR."framework/navigation/listings_page_links.php"); | |||
<syntaxhighlight lang=" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===JavaScript=== | |||
Handlers rolled into | |||
Album listings: | |||
<syntaxhighlight lang="javascript"> | |||
<syntaxhighlight lang=" | $('#listings-container').galleries('bindListingsHandlers'); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>.alb-nav</code> click > <code>$.galleries('gotoAlbumPage')</code> | |||
==Sorting== | ==Sorting== | ||
| Line 165: | Line 148: | ||
*[[Albums CMS Configuration]] | *[[Albums CMS Configuration]] | ||
*[[Sorting Listings]] | *[[Sorting Listings]] | ||
Latest revision as of 20:37, 11 September 2014
Application[edit]
See also: Albums CMS Design Principles
PHP[edit]
Album listings pages[edit]
- Add shared album listings template on the page, enclosed in a `<div>
classlistings album-listingsdata-tidattributeValue is thesite_sectionrepresenting the listings content.- Used for all shared AJAX scripts.
data-p` attribute- Value is the position of the first record on the page within the entire set of matching records.
- Used for sorting.
Example:
<div class="listings album-listings" data-tid="<?=$filters->site_section->id->value ?>" data-p="<?=$filters->calc_rec_position()?>"> <? include (CMS_COMMON_TEMPLATE_DIR."content/albums/album_listings.php"); ?> </div>
Album details pages[edit]
~~TK~~
Javascript[edit]
Album listings pages[edit]
$(document).ready(function() {
/* Binds AJAX functionality to album listings elements */
$('.album-listings').galleries('bindAlbumListingsHandlers');
});
Album details pages[edit]
$(document).ready(function() {
/* retrieves gallery content */
$('.gallery-listings').galleries('retrieveGallery');
});
AJAX[edit]
Assign AJAX handlers through the Content Properties CMS.
- Listings
/_ajax/utils/listings.php - Delete record
/_ajax/utils/delete_record.php - Resort
/_ajax/utils/resort.php - Update Cache
/_ajax/utils/update_cache.php
PHP templates[edit]
Listings pages[edit]
This comes into play in album listings where there is an expand button for each of the albums which reveals the album's gallery.
Album details and edit pages[edit]
PHP include that inserts the gallery container element into the page. It allows for either default listing content, or custom gallery listings content:
<? include (CMS_COMMON_TEMPLATE_DIR."forms/images/gallery_listings_container.php"); ?>
Image rollovers[edit]
See Image Rollovers (Poshytip)
Image lightbox[edit]
Markup[edit]
- Surround thumbnail
<img>element in<a>tags with the following attributes:href="javascript:void(0)" rel="nofollow"class="img-details-link"
This is the selector used to assign theonclickhandler.data-id="[IMAGE_LINK_ID]"data-tid="[GALLERY_SECTION_ID]"data-op="view"ordata-op="details"
This allows the jQuery handler to retrieve the correct AJAX script to call to retrieve the details dialog content.
- Note that it doesn't seem to work having this link around the preview image. I.e. it's not immediately apparent that it's possible to click on the tooltip preview of the image to open up a full-sized version of the image in a lightbox.
JavaScript[edit]
$('img-details-link')onclickhandler opens a dialog containing the full-resolution version of the image.onclickhandler defined in$.galleries('bindAlbumListingsHandlers')- The
onclickhandler invokes$.formDialog('open', {dialogClass, 'gallery-dialog'})
CMS[edit]
- Details URI:
/_ajax/images/image_details.php
This returns markup containing the full-resolution version of the image to be displayed in the lightbox dialog.
Inserting an "add image" button[edit]
Markup[edit]
<button class="add-img-btn" data-id="<?=$img->id->value?>" data-pid="<?=$input->id->value?>" data-tid="<?=$img->type_id->value ?>" title="add image">add image</button>
JavaScript[edit]
$('.add-img-btn', $p)
.iconButton('addchild')
.on('click', methods.editImage); /* "methods" in the context of $.galleries() */
The $('.add-img-btn') handler is rolled into $.galleries('bindGalleryHandlers').
AJAX handler script[edit]
The handler script is determined by section_properties.upload_uri. If no value is found in that column, the code falls back on section_properties.edit_uri.
That page will expect a combination of values to be passed in via the id, pid, and tid arguments. Only tid (type id) is strictly required. pid (parent id) can be null in cases when creating a new parent record and uploading images simultaneously. id (image link record id) can be null in cases when uploading a new image.
Pagination[edit]
PHP[edit]
Album listings:
include (COMMON_TEMPLATE_DIR."framework/navigation/listings_page_links.php");
JavaScript[edit]
Handlers rolled into Album listings:
$('#listings-container').galleries('bindListingsHandlers');
.alb-nav click > $.galleries('gotoAlbumPage')
Sorting[edit]
JavaScript[edit]
LITTLED.Gallery.configureSorting(parent_dom_id) which is rolled into LITTLED.Gallery.bindGalleryHandlers(parent_dom_id).
Markup[edit]
Container and sortable elements selectors are table.gallery-listings and tr.page-row or any div selector passed to LITTLED.Gallery.configureSorting() and .page-cell for the sortable selector.
AJAX handler script[edit]
Specified through with "Sections" CMS > Content Type > Sorting URI. The generic shared script is /_ajax/utils/resort.php. See Sorting Listings for more details.