Editing
Updating Cached Front-Facing Content After Gallery Edits
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Overview == Documentation of the process of refreshing cached front-facing content after editing gallery images in the Albums CMS. == Use cases == * Add a new image to the gallery * Edit an existing image in the gallery * Delete an existing image in the gallery * Click "update cache" button for the gallery * Update the Album's cache == Considerations == The routine that generates the gallery listings markup for the CMS should be separate from the routine that is run after editing operations. Toggling a gallery, or fetching a gallery on an album's details page should not cause the front-end cache to be updated even though the editing AJAX operations and viewing AJAX operations should share the logic that generates the gallery listings markup. == Operations requiring cache updates == * Add a page/image to a gallery. * Edit a page/image in a gallery. * Delete a page/image in a gallery. * Change the order of pages/images in a gallery. == Operations and their shared default handlers == * Add/edit a page image ** `/_ajax/images/edit_image.php` ** `cache_class::refresh_content_after_edit()` → `cache_class::refresh_content_after_image_edit()` * Delete a page image ** `/_ajax/images/del_image.php` ** `cache_class::refresh_content_after_edit()` → `cache_class::refresh_content_after_image_edit()` * Fetch gallery listings markup ** `/_ajax/images/gallery_listings.php` ** `cache_class::retrieve_gallery_listings_content()` falling back on `cache_class::refresh_content_after_edit()` * Resort page images ** `/_ajax/utils/resort.php` ** `resort_class` (local to site) → `resort_base_class` (shared) ** `resort_class::save()` (after calling `resort_class::update_positions()`) ** <span style="font-style:italic;color:red">N.B. The logic to update the front-end content cache doesn't exist in this routine currently.</span> ** The logic to implement updating the front-end content cache should probably be added to `/_ajax/utils/resort.php` after the call to `resort_class::update_positions()` *** Include `cache_class` if it exists on the local site. *** If `cache_class` has method `update_frontend_content_cache()` **** Load the appropriate object (using `cache_class::set_content_and_filters()` **** Call `cache_class::update_frontend_content_cache()` == Adding logic to update front-end cached content after page image edits == The site's local `cache_class` should have 2 routines defined: `refresh_content_after_image_edit($content, $filters, $json)` and `retrieve_gallery_listings_content($content, $filters, $json)`. `cache_class::retrieve_gallery_listings_content()` simply loads the gallery listings template, populates it with data, and returns the resulting markup. `cache_class::refresh_content_after_image_edit()` calls `cache_class::retrieve_gallery_listings_content()` and then executes the logic to update the front-end cached content. For example: <syntaxhighlight lang="php"> public static function refresh_content_after_image_edit ( &$content, &$filters, &$json ) { switch($content->site_section->id->value) { case comics_class::PAGE_SECTION_ID: case sketchbook_class::PAGE_SECTION_ID: case stasis_class::PAGE_SECTION_ID: cache_class::retrieve_gallery_listings_content($content, $filters, $json); cache_class::update_parent_frontend_cache($content, $filters, $json); break; } } public static function update_parent_frontend_cache( &$content, &$filters, &$json ) { if ($content instanceof image_link_class) { if ($content->parent_id->value > 0) { $parent = null; $content_type_id = $content->get_parent_content_type_id(); if ($content_type_id) { cache_class::set_content($content_type_id, $parent); if (is_object($parent) && method_exists($parent, "update_cache")) { $parent->id->value = $content->parent_id->value; $parent->read(true); $json->status->value .= $parent->update_cache(); } } } } } </syntaxhighlight> == Examples == * [http://damienjay.com/hostmgr/comics/|damienjay.com comics and sketchbook CMS] [[Category:Albums CMS]] [[Category:CMS Documentation]] [[Category:JQuery/AJAX]]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information